Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Main Actor warnings #113

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
@testable import SectionKit
import XCTest

@MainActor
internal final class CollectionViewContextExtensionsTests: XCTestCase {
// MARK: - dequeueReusableCell
final class CollectionViewContextExtensionsTests: XCTestCase {
private var context: MockCollectionViewContext!

internal func testDequeueReusableCellForIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableCell")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
@MainActor
override func setUp() {
super.setUp()
context = MockCollectionViewContext(
collectionView: UICollectionView(
frame: .zero,
collectionViewLayout: UICollectionViewFlowLayout()
),
errorHandler: MockErrorHandler()
)
}

override func tearDown() {
context = nil
super.tearDown()
}

// MARK: - dequeueReusableCell

@MainActor
func testDequeueReusableCellForIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableCell")
context._dequeueReusableCell = { cellType, indexPath in
XCTAssert(cellType === MockCollectionViewCell.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -21,12 +36,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableCellForSectionIndexPathWithExplicitType() {
@MainActor
func testDequeueReusableCellForSectionIndexPathWithExplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableCell")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableCell = { cellType, indexPath in
XCTAssert(cellType === MockCollectionViewCell.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -37,12 +49,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableCellForSectionIndexPathWithImplicitType() {
@MainActor
func testDequeueReusableCellForSectionIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableCell")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableCell = { cellType, indexPath in
XCTAssert(cellType === MockCollectionViewCell.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -55,12 +64,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {

// MARK: - dequeueReusableHeaderView

internal func testDequeueReusableHeaderViewForIndexPathWithImplicitType() {
@MainActor
func testDequeueReusableHeaderViewForIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableHeaderView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableHeaderView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -71,12 +77,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableHeaderViewForSectionIndexPathWithExplicitType() {
@MainActor
func testDequeueReusableHeaderViewForSectionIndexPathWithExplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableHeaderView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableHeaderView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -87,12 +90,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableHeaderViewForSectionIndexPathWithImplicitType() {
@MainActor
func testDequeueReusableHeaderViewForSectionIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableHeaderView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableHeaderView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -105,12 +105,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {

// MARK: - dequeueReusableFooterView

internal func testDequeueReusableFooterViewForIndexPathWithImplicitType() {
@MainActor
func testDequeueReusableFooterViewForIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableFooterView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableFooterView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -121,12 +118,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableFooterViewForSectionIndexPathWithExplicitType() {
@MainActor
func testDequeueReusableFooterViewForSectionIndexPathWithExplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableFooterView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableFooterView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand All @@ -137,12 +131,9 @@ internal final class CollectionViewContextExtensionsTests: XCTestCase {
waitForExpectations(timeout: 1)
}

internal func testDequeueReusableFooterViewForSectionIndexPathWithImplicitType() {
@MainActor
func testDequeueReusableFooterViewForSectionIndexPathWithImplicitType() {
let testExpectation = expectation(description: "Should invoke dequeueReusableFooterView")
let context = MockCollectionViewContext(
collectionView: UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()),
errorHandler: MockErrorHandler()
)
context._dequeueReusableFooterView = { cellType, indexPath in
XCTAssert(cellType === MockCollectionReusableView.self)
XCTAssertEqual(indexPath, IndexPath(item: 0, section: 0))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@testable import SectionKit
import XCTest

@MainActor
internal final class CollectionViewContextSizeTests: XCTestCase {
internal func testContainerSize() {
final class CollectionViewContextSizeTests: XCTestCase {
@MainActor
func testContainerSize() {
let rect = CGRect(x: 1, y: 2, width: 4, height: 8)
let collectionView = UICollectionView(frame: rect, collectionViewLayout: UICollectionViewFlowLayout())
let context = MainCollectionViewContext(
Expand All @@ -14,7 +14,8 @@ internal final class CollectionViewContextSizeTests: XCTestCase {
XCTAssertEqual(context.containerSize, rect.size)
}

internal func testCustomContainerInset() {
@MainActor
func testCustomContainerInset() {
let insets = UIEdgeInsets(top: 1, left: 2, bottom: 4, right: 8)
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
collectionView.contentInset = insets
Expand All @@ -26,7 +27,8 @@ internal final class CollectionViewContextSizeTests: XCTestCase {
XCTAssertEqual(context.customContainerInset, insets)
}

internal func testAdjustedContainerInset() {
@MainActor
func testAdjustedContainerInset() {
let insets = UIEdgeInsets(top: 1, left: 2, bottom: 4, right: 8)
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
collectionView.contentInset = insets
Expand All @@ -38,7 +40,8 @@ internal final class CollectionViewContextSizeTests: XCTestCase {
XCTAssertEqual(context.adjustedContainerInset, insets)
}

internal func testInsetContainerSize() {
@MainActor
func testInsetContainerSize() {
let rect = CGRect(x: 16, y: 32, width: 64, height: 128)
let insets = UIEdgeInsets(top: 1, left: 2, bottom: 4, right: 8)
let collectionView = UICollectionView(frame: rect, collectionViewLayout: UICollectionViewFlowLayout())
Expand Down
Loading
Loading