diff --git a/Package@swift-5.10.swift b/Package@swift-5.10.swift new file mode 100644 index 00000000..0fb17678 --- /dev/null +++ b/Package@swift-5.10.swift @@ -0,0 +1,79 @@ +// swift-tools-version:5.10 + +import PackageDescription + +let packageName = "Layout" + +enum SwiftLint { + static let plugin = "SwiftLintPlugin-\(packageName)" + static let binary = "SwiftLintBinary-\(packageName)" +} + +let package = Package( + name: packageName, + platforms: [ + .iOS(.v13), + ], + products: [ + .library( + name: "Layout", + targets: ["Layout"]), + ], + dependencies: [ + .package( + url: "https://github.com/Quick/Nimble.git", + from: "13.0.0"), + .package( + url: "https://github.com/pointfreeco/swift-snapshot-testing.git", + from: "1.15.0"), + ], + targets: [ + .target( + name: "Layout", + swiftSettings: .swiftSettings, + plugins: [ + .plugin(name: SwiftLint.plugin), + ]), + .testTarget( + name: "LayoutTests", + dependencies: [ + "Layout", + "Nimble", + .product(name: "SnapshotTesting", package: "swift-snapshot-testing"), + ], + exclude: [ + "__Snapshots__", + "UIKit/__Snapshots__", + ], + swiftSettings: .swiftSettings, + plugins: [ + .plugin(name: SwiftLint.plugin), + ]), + .plugin( + name: "SwiftLintCommand", + capability: .command(intent: .custom(verb: "swiftlint", description: "SwiftLint Command Plugin")), + dependencies: [ + .target(name: SwiftLint.binary) + ]), + .plugin( + name: SwiftLint.plugin, + capability: .buildTool(), + dependencies: [ + .target(name: SwiftLint.binary) + ], + path: "Plugins/SwiftLintPlugin"), + .binaryTarget( + name: SwiftLint.binary, + url: "https://github.com/realm/SwiftLint/releases/download/0.54.0/SwiftLintBinary-macos.artifactbundle.zip", + checksum: "963121d6babf2bf5fd66a21ac9297e86d855cbc9d28322790646b88dceca00f1"), + ] +) + +extension Array where Element == SwiftSetting { + + static var swiftSettings: [SwiftSetting] { + [ + .enableExperimentalFeature("StrictConcurrency"), + ] + } +} diff --git a/Sources/Layout/LayoutItem/LayoutItems/ViewLayoutItem.swift b/Sources/Layout/LayoutItem/LayoutItems/ViewLayoutItem.swift index fc0f2248..16c949ae 100644 --- a/Sources/Layout/LayoutItem/LayoutItems/ViewLayoutItem.swift +++ b/Sources/Layout/LayoutItem/LayoutItems/ViewLayoutItem.swift @@ -9,6 +9,8 @@ import UIKit +@preconcurrency +@MainActor internal final class ViewLayoutItem: LayoutItem { // MARK: - LayoutBoundary diff --git a/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift b/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift index 53c338f2..660491e5 100644 --- a/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift +++ b/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class ConstraintsBuilderTests: XCTestCase { + @MainActor func testConstraintsBuilder() { // GIVEN diff --git a/Tests/LayoutTests/Builders/LayoutBuilderTests.swift b/Tests/LayoutTests/Builders/LayoutBuilderTests.swift index e52624a6..9af694af 100644 --- a/Tests/LayoutTests/Builders/LayoutBuilderTests.swift +++ b/Tests/LayoutTests/Builders/LayoutBuilderTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class LayoutBuilderTests: XCTestCase { + @MainActor func testLayoutBuilder() { // GIVEN diff --git a/Tests/LayoutTests/LayoutExampleTests.swift b/Tests/LayoutTests/LayoutExampleTests.swift index 53c8114d..41d2a1c5 100644 --- a/Tests/LayoutTests/LayoutExampleTests.swift +++ b/Tests/LayoutTests/LayoutExampleTests.swift @@ -11,11 +11,11 @@ import Nimble import XCTest -@MainActor final class LayoutExampleTests: XCTestCase { // MARK: - Readme + @MainActor func testReadmeExample() { // GIVEN @@ -81,6 +81,7 @@ final class LayoutExampleTests: XCTestCase { // MARK: - Layout + @MainActor func testLayoutDocumentationExample() { // GIVEN @@ -94,6 +95,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testLayoutBuilderDocumentationExample() { // GIVEN @@ -115,6 +117,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testHorizontallyCenteringDocumentationExample() { // GIVEN @@ -142,6 +145,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testVerticallyCenteringDocumentationExample() { // GIVEN @@ -171,6 +175,7 @@ final class LayoutExampleTests: XCTestCase { // MARK: - LayoutItem + @MainActor func testSingleLayoutItemDocumentationExample() { // GIVEN @@ -185,6 +190,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testMultipleLayoutItemsDocumentationExample() { // GIVEN @@ -201,6 +207,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testHorizontallyCenteringLayoutItemDocumentationExample() { // GIVEN @@ -228,6 +235,7 @@ final class LayoutExampleTests: XCTestCase { } } + @MainActor func testVerticallyCenteringLayoutItemDocumentationExample() { // GIVEN diff --git a/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift b/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift index 85b9a0fb..2061bf38 100644 --- a/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift @@ -12,9 +12,9 @@ import Layout import Nimble import XCTest -@MainActor final class UIViewLayoutItemTests: XCTestCase { + @MainActor func testLayoutItemView() { // GIVEN @@ -26,6 +26,7 @@ final class UIViewLayoutItemTests: XCTestCase { expect(view.layoutItemView) === view } + @MainActor func testSuperviewConstraints() { // GIVEN @@ -37,6 +38,7 @@ final class UIViewLayoutItemTests: XCTestCase { expect(view.superviewConstraints(view)).to(beEmpty()) } + @MainActor func testLayoutBoundary() { // GIVEN @@ -57,6 +59,7 @@ final class UIViewLayoutItemTests: XCTestCase { expect(boundary.bottom) == view.bottomAnchor } + @MainActor func testLayoutCenter() { // GIVEN @@ -73,6 +76,7 @@ final class UIViewLayoutItemTests: XCTestCase { expect(center.centerY) == view.centerYAnchor } + @MainActor func testLayoutSize() { // GIVEN @@ -89,6 +93,7 @@ final class UIViewLayoutItemTests: XCTestCase { expect(size.height) == view.heightAnchor } + @MainActor func testLayoutBaseline() { // GIVEN diff --git a/Tests/LayoutTests/LayoutItem/LayoutItems/ViewLayoutItemTests.swift b/Tests/LayoutTests/LayoutItem/LayoutItems/ViewLayoutItemTests.swift index fca8ce35..87847af1 100644 --- a/Tests/LayoutTests/LayoutItem/LayoutItems/ViewLayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItem/LayoutItems/ViewLayoutItemTests.swift @@ -11,9 +11,9 @@ import Nimble import XCTest -@MainActor final class ViewLayoutItemTests: XCTestCase { + @MainActor func testInitLayoutItemViewSuperviewConstraints() { // GIVEN @@ -43,6 +43,7 @@ final class ViewLayoutItemTests: XCTestCase { expect(layoutItems === [viewLayoutItem]) == true } + @MainActor func testLayoutBoundary() { // GIVEN @@ -63,6 +64,7 @@ final class ViewLayoutItemTests: XCTestCase { expect(boundary.bottom) == view.bottom } + @MainActor func testLayoutCenter() { // GIVEN @@ -79,6 +81,7 @@ final class ViewLayoutItemTests: XCTestCase { expect(center.centerY) == view.centerY } + @MainActor func testLayoutSize() { // GIVEN @@ -95,6 +98,7 @@ final class ViewLayoutItemTests: XCTestCase { expect(size.height) == view.height } + @MainActor func testLayoutBaseline() { // GIVEN diff --git a/Tests/LayoutTests/LayoutItemTests.swift b/Tests/LayoutTests/LayoutItemTests.swift index 8bef21a6..4aee9a67 100644 --- a/Tests/LayoutTests/LayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItemTests.swift @@ -11,11 +11,11 @@ import Layout import Nimble import XCTest -@MainActor final class LayoutItemTests: XCTestCase { // MARK: - Properties + @MainActor func testIdentifier() { // GIVEN @@ -38,6 +38,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Identifier + @MainActor func testIDWithIdentifier() { // GIVEN @@ -61,6 +62,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Size + @MainActor func testSizePriority() { assertLayout { view in view.layout { @@ -83,6 +85,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testSizeWidthHeightPriority() { assertLayout { view in view.layout { @@ -107,6 +110,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Width + @MainActor func testWidthIsRelationToConstantPriority() { // swiftlint:disable:next closure_body_length @@ -169,6 +173,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testWidthWithConstantPriority() { assertLayout { view in @@ -197,6 +202,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Height + @MainActor func testHeightIsRelationToConstantPriority() { // swiftlint:disable:next closure_body_length @@ -259,6 +265,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testHeightWithConstantPriority() { assertLayout { view in @@ -287,6 +294,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Square + @MainActor func testSquareWithLengthPriority() { assertLayout { view in view.layout { @@ -309,6 +317,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testSquare() { assertLayout { view in view.layout { @@ -333,6 +342,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Aspect Ratio + @MainActor func testAspectRatioWithRatioPriority() { assertLayout { view in view.layout { @@ -359,6 +369,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Center + @MainActor func testCenterOffsetPriority() { assertLayout { view in view.layout { @@ -387,6 +398,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testCenterWithAxisOffsetMultiplierPriority() { assertLayout { view in view.layout { @@ -433,6 +445,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testCenterBetweenLeadingAndTrailing() { assertLayout(devices: Device.allTestDevices) { view in view.layout( @@ -445,6 +458,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testCenterBetweenTopAndBottom() { assertLayout(devices: Device.allTestDevices) { view in view @@ -460,6 +474,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Attributes + @MainActor func testToAttributeIsRelationMultiplierConstantPriority() { assertLayout { view in view.layout { @@ -507,6 +522,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToAttributeIsRelationMultiplierConstantPriority_givenRelation() { assertLayout { view in view.layout { @@ -547,6 +563,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToAttributesConstantPriority() { assertLayout { view in view.layout { @@ -577,6 +594,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Edges + @MainActor func testToEdgesInsetsPriorityDirectional() { assertLayout { view in view.layout { @@ -604,6 +622,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToEdgesInsetsPriorityCanonical() { assertLayout { view in view.layout { @@ -624,6 +643,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToEdgesWithEdgesInsetPriorityDirectional() { assertLayout { view in view.layout { @@ -653,6 +673,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToEdgesCanonicalEdgesInsetPriority() { assertLayout { view in view.layout { @@ -687,6 +708,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToSideEdgesInsetPriority() { assertLayout { view in view.layout { @@ -720,6 +742,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Margins + @MainActor func testToMargins_throwsAssertion() { // GIVEN @@ -741,6 +764,7 @@ final class LayoutItemTests: XCTestCase { expect(item.superviewConstraints(item).count) == 4 } + @MainActor func testToMarginsInsetsPriorityDirectional() { assertLayout(devices: Device.portraitTestDevices + Device.modernLandscapeTestDevices) { view in view.layout { @@ -763,6 +787,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToMarginsInsetsPriorityCanonical() { assertLayout(devices: Device.portraitTestDevices + Device.modernLandscapeTestDevices) { view in view.layout { @@ -783,6 +808,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToMarginsWithEdgesInsetPriorityDirectional() { assertLayout(devices: Device.portraitTestDevices + Device.modernLandscapeTestDevices) { view in view.layout { @@ -808,6 +834,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToMarginsCanonicalEdgesInsetPriority() { assertLayout(devices: Device.portraitTestDevices + Device.modernLandscapeTestDevices) { view in view.layout { @@ -839,6 +866,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToSideMarginsInsetPriority() { assertLayout(devices: Device.portraitTestDevices + Device.modernLandscapeTestDevices) { view in view.layout { @@ -872,6 +900,7 @@ final class LayoutItemTests: XCTestCase { // MARK: - Safe Area + @MainActor func testToSafeArea_throwsAssertion() { // GIVEN @@ -893,6 +922,7 @@ final class LayoutItemTests: XCTestCase { expect(item.superviewConstraints(item).count) == 4 } + @MainActor func testToSafeAreaInsetsPriorityDirectional() { assertLayout(devices: Device.allTestDevices) { view in view.layout { @@ -920,6 +950,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToSafeAreaInsetsPriorityCanonical() { assertLayout(devices: Device.allTestDevices) { view in view.layout { @@ -940,6 +971,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToSafeAreaWithEdgesInsetPriorityDirectional() { assertLayout(devices: Device.allTestDevices) { view in view.layout { @@ -960,6 +992,7 @@ final class LayoutItemTests: XCTestCase { } } + @MainActor func testToSafeAreaCanonicalEdgesInsetPriority() { assertLayout(devices: Device.allTestDevices) { view in view.layout { diff --git a/Tests/LayoutTests/LayoutTests.swift b/Tests/LayoutTests/LayoutTests.swift index 8fb3381f..8d99849a 100644 --- a/Tests/LayoutTests/LayoutTests.swift +++ b/Tests/LayoutTests/LayoutTests.swift @@ -11,11 +11,11 @@ import Nimble import XCTest -@MainActor final class LayoutTests: XCTestCase { // MARK: - Initialization + @MainActor func testInitWithViewMetrics() { // GIVEN @@ -47,6 +47,7 @@ final class LayoutTests: XCTestCase { expect(layout2.metrics["height"] as? Int) == 100 } + @MainActor func testInitWithViewMetricsWithItem() { // GIVEN @@ -88,6 +89,7 @@ final class LayoutTests: XCTestCase { expect(layoutTwo.items["subview2"]) === subview2 } + @MainActor func testInitWithViewMetricsLayoutBuilderItems() { // GIVEN @@ -118,6 +120,7 @@ final class LayoutTests: XCTestCase { expect(layout2.items["subview2"]) === subview2 } + @MainActor func testInitWithViewMetricsItems() { // GIVEN @@ -147,6 +150,7 @@ final class LayoutTests: XCTestCase { // MARK: - Adding Items + @MainActor func testAddItem() { // GIVEN @@ -169,6 +173,7 @@ final class LayoutTests: XCTestCase { expect(layout.items["subview"]) === subview } + @MainActor func testAddItems() { // GIVEN @@ -198,6 +203,7 @@ final class LayoutTests: XCTestCase { // MARK: - Adding Constraints + @MainActor func testAddingConstraintsBuilderConstraints() { // GIVEN @@ -236,6 +242,7 @@ final class LayoutTests: XCTestCase { expect(layout.constraints) == [widthConstraint, heightConstraint] } + @MainActor func testAddingConstraints() { // GIVEN @@ -265,6 +272,7 @@ final class LayoutTests: XCTestCase { // MARK: - Constrain + @MainActor func testConstrainViewAttributeIsRelationToTargetAttributeOfTargetViewMultiplierConstant() { // GIVEN @@ -319,6 +327,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainAnchorIsRelationToTargetAnchorConstantPriority() { // GIVEN @@ -420,6 +429,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainAnchorIsRelationToTargetAnchorMultiplierConstantPriority() { // GIVEN @@ -489,6 +499,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainAnchorIsRelationToConstantPriority() { // GIVEN @@ -534,6 +545,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainViewToTargetViewInset() { // GIVEN @@ -565,6 +577,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainViewToTargetViewInsetsDirectional() { // GIVEN @@ -588,6 +601,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testConstrainViewToTargetViewInsetsCanonical() { // GIVEN @@ -613,6 +627,7 @@ final class LayoutTests: XCTestCase { // MARK: - Equal + @MainActor func testEqualAttributeWithViews() { // GIVEN @@ -642,6 +657,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testEqualAttributesWithViews() { // GIVEN @@ -664,6 +680,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testEqualAttributesWithViews_givenEmptyArray() { // GIVEN @@ -698,6 +715,7 @@ final class LayoutTests: XCTestCase { expect(layout.constraints.count) == 1 } + @MainActor func testEqualSizeWithViews() { // GIVEN @@ -722,6 +740,7 @@ final class LayoutTests: XCTestCase { // MARK: - Center + @MainActor func testCenterViewBetweenLeadingAndTrailingPriority() { // GIVEN @@ -756,6 +775,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testCenterViewBetweenLeadingAndTrailingPriority_givenNilSuperview() { // GIVEN @@ -782,6 +802,7 @@ final class LayoutTests: XCTestCase { expect(layout.constraints.count) == 3 } + @MainActor func testCenterViewBetweenTopAndBottomPriority() { // GIVEN @@ -816,6 +837,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testCenterViewBetweenTopAndBottomPriority_givenNilSuperview() { // GIVEN @@ -844,6 +866,7 @@ final class LayoutTests: XCTestCase { // MARK: - Stack + @MainActor func testHorizontalViewsSpacingDirectionPriorityAlignment() { // GIVEN @@ -902,6 +925,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testHorizontalViewsSpacingDirectionPriorityAlignment_givenAlignment() { // GIVEN @@ -935,6 +959,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testHorizontalViewsSpacingDirectionPriorityAlignment_givenEmptyArray() { // GIVEN @@ -969,6 +994,7 @@ final class LayoutTests: XCTestCase { expect(layout.constraints.count) == 1 } + @MainActor func testVerticalViewsSpacingPriorityAlignment() { // GIVEN @@ -1009,6 +1035,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testVerticalViewsSpacingPriorityAlignment_givenAlignment() { // GIVEN @@ -1037,6 +1064,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testVerticalViewsSpacingPriorityAlignment_givenEmptyArray() { // GIVEN @@ -1073,6 +1101,7 @@ final class LayoutTests: XCTestCase { // MARK: - Visual Format Language + @MainActor func testHorizontalWithFormatMetricsOptions_givenDefaults() { // GIVEN @@ -1099,6 +1128,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testHorizontalWithFormatMetricsOptions_givenOption() { // GIVEN @@ -1139,6 +1169,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testVerticalWithFormatMetricsOptions_givenDefaults() { // GIVEN @@ -1165,6 +1196,7 @@ final class LayoutTests: XCTestCase { } } + @MainActor func testVerticalWithFormatMetricsOptions_givenOption() { // GIVEN @@ -1207,6 +1239,7 @@ final class LayoutTests: XCTestCase { // MARK: - Activation + @MainActor func testActivateAndDeactivate() { // GIVEN @@ -1264,6 +1297,7 @@ final class LayoutTests: XCTestCase { // MARK: - Priority + @MainActor func testRequire() { // GIVEN @@ -1314,6 +1348,7 @@ final class LayoutTests: XCTestCase { expect(requiredLayout) === layout } + @MainActor func testWithPriority() { // GIVEN @@ -1361,6 +1396,7 @@ final class LayoutTests: XCTestCase { expect(highPriorityLayout) === layout } + @MainActor func testPrioritizeWithPriority() { // GIVEN @@ -1409,6 +1445,7 @@ final class LayoutTests: XCTestCase { // MARK: - Animation + @MainActor func testUpdate() { // GIVEN diff --git a/Tests/LayoutTests/Swift/ArrayTests.swift b/Tests/LayoutTests/Swift/ArrayTests.swift index e0e5e676..8457ab79 100644 --- a/Tests/LayoutTests/Swift/ArrayTests.swift +++ b/Tests/LayoutTests/Swift/ArrayTests.swift @@ -11,11 +11,11 @@ import Layout import Nimble import XCTest -@MainActor final class ArrayTests: XCTestCase { // MARK: - Activation + @MainActor func testActivateAndDeactivate() { // GIVEN @@ -69,6 +69,7 @@ final class ArrayTests: XCTestCase { // MARK: - Priority + @MainActor func testRequire() { // GIVEN @@ -107,6 +108,7 @@ final class ArrayTests: XCTestCase { expect(requiredConstraints) == constraints } + @MainActor func testWithPriority() { // GIVEN @@ -148,6 +150,7 @@ final class ArrayTests: XCTestCase { expect(highPriorityConstraints) == constraints } + @MainActor func testPrioritizeWithPriority() { // GIVEN diff --git a/Tests/LayoutTests/Swift/CollectionTests.swift b/Tests/LayoutTests/Swift/CollectionTests.swift index 7d615444..ed298c92 100644 --- a/Tests/LayoutTests/Swift/CollectionTests.swift +++ b/Tests/LayoutTests/Swift/CollectionTests.swift @@ -11,9 +11,9 @@ import Nimble import XCTest -@MainActor final class CollectionTests: XCTestCase { + @MainActor func testActivateAndDeactivate() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift index 7d6eddcd..afd4872a 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift @@ -11,11 +11,11 @@ import Layout import Nimble import XCTest -@MainActor final class NSLayoutConstraintTests: XCTestCase { // MARK: - Visual Format Language + @MainActor func testConstraintsFormatsViewsMetricsOptions() { // GIVEN @@ -45,6 +45,7 @@ final class NSLayoutConstraintTests: XCTestCase { } } + @MainActor func testConstraintsFormatsViewsMetricsOptions_givenRightToLeftFormatOption() { // GIVEN @@ -78,6 +79,7 @@ final class NSLayoutConstraintTests: XCTestCase { // MARK: - Activation + @MainActor func testActivateAndDeactivate() { // GIVEN @@ -116,6 +118,7 @@ final class NSLayoutConstraintTests: XCTestCase { // MARK: - Priority + @MainActor func testRequire() { // GIVEN @@ -133,6 +136,7 @@ final class NSLayoutConstraintTests: XCTestCase { expect(requiredConstraint) === constraint } + @MainActor func testWithPriority() { // GIVEN @@ -153,6 +157,7 @@ final class NSLayoutConstraintTests: XCTestCase { expect(highPriorityConstraint) === constraint } + @MainActor func testPrioritizeWithPriority() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift b/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift index a93e168e..342dfccc 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class NSLayoutDimensionTests: XCTestCase { + @MainActor func testConstraintIsRelationToAnchorMultiplierConstant_givenDefaults() { // GIVEN @@ -35,6 +35,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorMultiplierConstant_givenMultiplier() { // GIVEN @@ -56,6 +57,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorMultiplierConstant_givenConstant() { // GIVEN @@ -77,6 +79,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorMultiplierConstant_givenGreaterThanOrEqualRelation() { // GIVEN @@ -98,6 +101,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorMultiplierConstant_givenLessThanOrEqualRelation() { // GIVEN @@ -119,6 +123,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToConstant_givenEqualRelation() { // GIVEN @@ -139,6 +144,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationConstant_givenGreaterThanRelation() { // GIVEN @@ -159,6 +165,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationConstant_givenLessThanRelation() { // GIVEN @@ -179,6 +186,7 @@ final class NSLayoutDimensionTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintWithConstant() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift b/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift index 5a9216a1..b2f3326c 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class NSLayoutXAxisAnchorTests: XCTestCase { + @MainActor func testConstraintIsRelationToAnchorConstant_givenDefaults() { // GIVEN @@ -35,6 +35,7 @@ final class NSLayoutXAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenConstant() { // GIVEN @@ -56,6 +57,7 @@ final class NSLayoutXAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenGreaterThanOrEqualRelation() { // GIVEN @@ -77,6 +79,7 @@ final class NSLayoutXAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenLessThanOrEqualRelation() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift b/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift index 74d93773..e6c7d462 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class NSLayoutYAxisAnchorTests: XCTestCase { + @MainActor func testConstraintIsRelationToAnchorConstant_givenDefaults() { // GIVEN @@ -35,6 +35,7 @@ final class NSLayoutYAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenConstant() { // GIVEN @@ -56,6 +57,7 @@ final class NSLayoutYAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenGreaterThanOrEqualRelation() { // GIVEN @@ -77,6 +79,7 @@ final class NSLayoutYAxisAnchorTests: XCTestCase { expect(constraint).to(match(expected)) } + @MainActor func testConstraintIsRelationToAnchorConstant_givenLessThanOrEqualRelation() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift b/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift index 8d951bfe..426166f6 100644 --- a/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift +++ b/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class UILayoutGuideTests: XCTestCase { + @MainActor func testLayoutBoundary() { // GIVEN @@ -34,6 +34,7 @@ final class UILayoutGuideTests: XCTestCase { expect(boundary.bottom) == guide.bottomAnchor } + @MainActor func testLayoutCenter() { // GIVEN @@ -50,6 +51,7 @@ final class UILayoutGuideTests: XCTestCase { expect(center.centerY) == guide.centerYAnchor } + @MainActor func testLayoutSize() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift b/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift index 9b50a7fb..dfa9f146 100644 --- a/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift @@ -13,11 +13,11 @@ import Nimble import UIKit import XCTest -@MainActor final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Builder + @MainActor func testUsingConstraints() { // GIVEN @@ -29,6 +29,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(view.translatesAutoresizingMaskIntoConstraints) == false } + @MainActor func testConstrainingSize_givenDefaults() { // GIVEN @@ -64,6 +65,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 20), isActive: true)) } + @MainActor func testConstrainingSize() { // GIVEN @@ -98,6 +100,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 20), isActive: true)) } + @MainActor func testConstrainingWidth_givenDefaults() { // GIVEN @@ -125,6 +128,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 10), isActive: true)) } + @MainActor func testConstrainingWidth() { // GIVEN @@ -152,6 +156,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 10), isActive: true)) } + @MainActor func testConstrainingHeight_givenDefaults() { // GIVEN @@ -179,6 +184,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 20), isActive: true)) } + @MainActor func testConstrainingHeight() { // GIVEN @@ -208,6 +214,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Size + @MainActor func testSizeConstraintsWithSize() { // GIVEN @@ -259,6 +266,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 40))) } + @MainActor func testSizeConstraintsWithWidthAndHeight() { // GIVEN @@ -312,6 +320,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Width + @MainActor func testWidthConstraintIsRelationToConstant() { // GIVEN @@ -361,6 +370,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 30))) } + @MainActor func testWidthConstraintWithConstant() { // GIVEN @@ -398,6 +408,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Height + @MainActor func testHeightConstraintIsRelationToConstant() { // GIVEN @@ -447,6 +458,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 60))) } + @MainActor func testHeightConstraintWithConstant() { // GIVEN @@ -484,6 +496,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Square + @MainActor func testSquareConstraintsWithLength() { // GIVEN @@ -513,6 +526,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 100))) } + @MainActor func testSquareConstraint() { // GIVEN @@ -536,6 +550,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Aspect Ratio + @MainActor func testAspectRatioConstraintWithRatio() { // GIVEN @@ -559,6 +574,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Equal + @MainActor func testEqualConstraintsForAttributeToViews() { // GIVEN @@ -592,6 +608,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Center + @MainActor func testCenterConstraintsOffset() { // GIVEN @@ -647,6 +664,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Attributes + @MainActor func testConstraintForAttributeIsRelationToSuperviewMultiplierConstant() { // GIVEN @@ -703,6 +721,7 @@ final class UIViewAutoLayoutTests: XCTestCase { constant: 5))) } + @MainActor func testConstraintForAttributeIsRelationToSuperviewMultiplierConstant_givenNilSuperview() { // GIVEN @@ -723,6 +742,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(view.constraints(toSuperview: [.top, .left])).notTo(beEmpty()) } + @MainActor func testConstraintForAttributeIsRelationToTargetAttributeOfTargetViewMultiplierConstant() { // GIVEN @@ -781,6 +801,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Edges + @MainActor func testEdgeConstraintsInset() { // GIVEN @@ -802,6 +823,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.bottom))) } + @MainActor func testEdgeConstraintsInset_givenInset() { // GIVEN @@ -824,6 +846,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.bottom, constant: -inset))) } + @MainActor func testEdgeConstraintsInsetsDirectional() { // GIVEN @@ -846,6 +869,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.bottom, constant: -insets.bottom))) } + @MainActor func testEdgeConstraintsInsetsCanonical() { // GIVEN @@ -868,6 +892,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.bottom, constant: -insets.bottom))) } + @MainActor func testSideEdgeConstraintsInset() { // GIVEN @@ -887,6 +912,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[1]).to(match(view.right.constraint(to: superview.right))) } + @MainActor func testSideEdgeConstraintsInset_givenInset() { // GIVEN @@ -909,6 +935,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Margins + @MainActor func testMarginConstraintsInset() { // GIVEN @@ -930,6 +957,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.margins.bottom))) } + @MainActor func testMarginConstraintsInset_givenInset() { // GIVEN @@ -952,6 +980,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.margins.bottom, constant: -inset))) } + @MainActor func testMarginConstraintsInsetsDirectional() { // GIVEN @@ -978,6 +1007,7 @@ final class UIViewAutoLayoutTests: XCTestCase { .to(match(view.bottom.constraint(to: superview.margins.bottom, constant: -insets.bottom))) } + @MainActor func testMarginConstraintsInsetsCanonical() { // GIVEN @@ -1000,6 +1030,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.margins.bottom, constant: -insets.bottom))) } + @MainActor func testSideMarginConstraintsInset() { // GIVEN @@ -1019,6 +1050,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[1]).to(match(view.right.constraint(to: superview.margins.right))) } + @MainActor func testSideMarginConstraintsInset_givenInset() { // GIVEN @@ -1041,6 +1073,7 @@ final class UIViewAutoLayoutTests: XCTestCase { // MARK: - Safe Area + @MainActor func testSafeAreaConstraintsInset() { // GIVEN @@ -1062,6 +1095,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.safeArea.bottom))) } + @MainActor func testSafeAreaConstraintsInset_givenInset() { // GIVEN @@ -1084,6 +1118,7 @@ final class UIViewAutoLayoutTests: XCTestCase { expect(constraints[3]).to(match(view.bottom.constraint(to: superview.safeArea.bottom, constant: -inset))) } + @MainActor func testSafeAreaConstraintsInsetsDirectional() { // GIVEN @@ -1110,6 +1145,7 @@ final class UIViewAutoLayoutTests: XCTestCase { .to(match(view.bottom.constraint(to: superview.safeArea.bottom, constant: -insets.bottom))) } + @MainActor func testSafeAreaConstraintsInsetsCanonical() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIView+FramesTests.swift b/Tests/LayoutTests/UIKit/UIView+FramesTests.swift index b9a53e91..d388416e 100644 --- a/Tests/LayoutTests/UIKit/UIView+FramesTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+FramesTests.swift @@ -12,9 +12,9 @@ import Layout import Nimble import XCTest -@MainActor final class UIViewFramesTests: XCTestCase { + @MainActor func testUsingFramesWithAutoresizingMask() { // GIVEN @@ -32,6 +32,7 @@ final class UIViewFramesTests: XCTestCase { expect(framedView) === view } + @MainActor func testDisablingIntrinsicSize() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift b/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift index acdbe578..6b5dad88 100644 --- a/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift @@ -13,9 +13,9 @@ import Nimble import UIKit import XCTest -@MainActor final class UIViewLayoutTests: XCTestCase { + @MainActor func testLayoutMetrics() { // GIVEN @@ -35,6 +35,7 @@ final class UIViewLayoutTests: XCTestCase { expect(layout.items.isEmpty) == true } + @MainActor func testLayoutMetricsWithItem() { // GIVEN @@ -57,6 +58,7 @@ final class UIViewLayoutTests: XCTestCase { expect(layout.items[identifier] as? UIView) == subview } + @MainActor func testLayoutMetricsWithItems() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIView+NSLayoutAnchorTests.swift b/Tests/LayoutTests/UIKit/UIView+NSLayoutAnchorTests.swift index 5f92e415..5ee549fd 100644 --- a/Tests/LayoutTests/UIKit/UIView+NSLayoutAnchorTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+NSLayoutAnchorTests.swift @@ -13,9 +13,9 @@ import Nimble import UIKit import XCTest -@MainActor final class UIViewNSLayoutAnchorTests: XCTestCase { + @MainActor func testAnchorForAxisAttributeXAxis() { // GIVEN @@ -31,6 +31,7 @@ final class UIViewNSLayoutAnchorTests: XCTestCase { expect(view.anchor(for: .centerX)) == view.centerX } + @MainActor func testAnchorForAttributeYAxis() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIViewControllerTests.swift b/Tests/LayoutTests/UIKit/UIViewControllerTests.swift index f8bdb6da..48830228 100644 --- a/Tests/LayoutTests/UIKit/UIViewControllerTests.swift +++ b/Tests/LayoutTests/UIKit/UIViewControllerTests.swift @@ -11,9 +11,9 @@ import Layout import Nimble import XCTest -@MainActor final class UIViewControllerTests: XCTestCase { + @MainActor func testSafeTopAndSafeBottom() { // GIVEN diff --git a/Tests/LayoutTests/UIKit/UIViewUILayoutGuideTests.swift b/Tests/LayoutTests/UIKit/UIViewUILayoutGuideTests.swift index d96ccd11..ffa876f0 100644 --- a/Tests/LayoutTests/UIKit/UIViewUILayoutGuideTests.swift +++ b/Tests/LayoutTests/UIKit/UIViewUILayoutGuideTests.swift @@ -11,14 +11,15 @@ import Nimble import XCTest -@MainActor final class UIViewUILayoutGuideTests: XCTestCase { + @MainActor func testMargins() { let view: UIView = .init() expect(view.margins) === view.layoutMarginsGuide } + @MainActor func testSafeArea() { let view: UIView = .init() expect(view.safeArea) === view.safeAreaLayoutGuide