diff --git a/Sources/Thumbprint/Components/Button.Theme.swift b/Sources/Thumbprint/Components/Button.Theme.swift index bd928a1..3bc118e 100644 --- a/Sources/Thumbprint/Components/Button.Theme.swift +++ b/Sources/Thumbprint/Components/Button.Theme.swift @@ -202,7 +202,7 @@ public extension Button { self.init(textStyle: textStyle, contentPadding: contentPadding, iconTextSpacing: Space.one) } - public static func height(for size: Size) -> CGFloat { + @MainActor public static func height(for size: Size) -> CGFloat { size.textStyle.dynamicFont.lineHeight + size.contentPadding.height * 2.0 } } diff --git a/Sources/Thumbprint/Font.swift b/Sources/Thumbprint/Font.swift index a34bb5c..534a9e4 100644 --- a/Sources/Thumbprint/Font.swift +++ b/Sources/Thumbprint/Font.swift @@ -49,42 +49,42 @@ public enum Font { // MARK: - Fonts that support scaling for accessibility. /// Font with title 1 style that supports scaling for accessibility. - public static var dynamicTitle1: UIFont { TextStyle.title1.dynamicFont } + @MainActor public static var dynamicTitle1: UIFont { TextStyle.title1.dynamicFont } /// Font with title 2 style that supports scaling for accessibility. - public static var dynamicTitle2: UIFont { TextStyle.title2.dynamicFont } + @MainActor public static var dynamicTitle2: UIFont { TextStyle.title2.dynamicFont } /// Font with title 3 style that supports scaling for accessibility. - public static var dynamicTitle3: UIFont { TextStyle.title3.dynamicFont } + @MainActor public static var dynamicTitle3: UIFont { TextStyle.title3.dynamicFont } /// Font with title 4 style that supports scaling for accessibility. - public static var dynamicTitle4: UIFont { TextStyle.title4.dynamicFont } + @MainActor public static var dynamicTitle4: UIFont { TextStyle.title4.dynamicFont } /// Font with title 5 style that supports scaling for accessibility. - public static var dynamicTitle5: UIFont { TextStyle.title5.dynamicFont } + @MainActor public static var dynamicTitle5: UIFont { TextStyle.title5.dynamicFont } /// Font with title 6 style that supports scaling for accessibility. - public static var dynamicTitle6: UIFont { TextStyle.title6.dynamicFont } + @MainActor public static var dynamicTitle6: UIFont { TextStyle.title6.dynamicFont } /// Font with title 7 style that supports scaling for accessibility. - public static var dynamicTitle7: UIFont { TextStyle.title7.dynamicFont } + @MainActor public static var dynamicTitle7: UIFont { TextStyle.title7.dynamicFont } /// Font with title 8 style that supports scaling for accessibility. - public static var dynamicTitle8: UIFont { TextStyle.title8.dynamicFont } + @MainActor public static var dynamicTitle8: UIFont { TextStyle.title8.dynamicFont } /// Font with text 1 style that supports scaling for accessibility. - public static var dynamicText1: UIFont { TextStyle.text1.dynamicFont } + @MainActor public static var dynamicText1: UIFont { TextStyle.text1.dynamicFont } /// Font with text 2 style that supports scaling for accesssibility. - public static var dynamicText2: UIFont { TextStyle.text2.dynamicFont } + @MainActor public static var dynamicText2: UIFont { TextStyle.text2.dynamicFont } /// Font with text 3 style that supports scaling for accessibility. - public static var dynamicText3: UIFont { TextStyle.text3.dynamicFont } + @MainActor public static var dynamicText3: UIFont { TextStyle.text3.dynamicFont } // MARK: - Testing /// Used by snapshot tests to forcefully apply the given trait collection. Do not use in application code. - public static var traitCollectionOverrideForTesting: UITraitCollection? + @MainActor public static var traitCollectionOverrideForTesting: UITraitCollection? private static var didRegisterFonts = false } @@ -115,7 +115,7 @@ public extension Font { didRegisterFonts = true } - static func scaledValue(_ value: CGFloat, for style: TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> CGFloat { + @MainActor static func scaledValue(_ value: CGFloat, for style: TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> CGFloat { UIFontMetrics(forTextStyle: style.uiFontTextStyle).scaledValue(for: value, compatibleWith: resolvedTraits(for: traitCollection)) } } @@ -175,7 +175,7 @@ public extension Font { } /// Font with this text style that supports scaling for accessibility. - public var dynamicFont: UIFont { + @MainActor public var dynamicFont: UIFont { Font.scaledFont(for: self) } @@ -185,7 +185,7 @@ public extension Font { /// When using attributed strings, UIContentSizeCategoryAdusting.adjustsFontForContentSizeCategory /// does not work, and therefore fonts must be configured with a specific trait collection /// and updated any time the preferred content size category on the relevant view changes. - public func scaledFont(compatibleWith traitCollection: UITraitCollection) -> UIFont { + @MainActor public func scaledFont(compatibleWith traitCollection: UITraitCollection) -> UIFont { Font.scaledFont(for: self, compatibleWith: traitCollection) } @@ -289,7 +289,7 @@ public extension UIContentSizeCategoryAdjusting { // MARK: - Private private extension Font { - private static func resolvedTraits(for traitCollection: UITraitCollection?) -> UITraitCollection? { + @MainActor private static func resolvedTraits(for traitCollection: UITraitCollection?) -> UITraitCollection? { switch (traitCollection, traitCollectionOverrideForTesting) { case (.none, .none): nil @@ -305,7 +305,7 @@ private extension Font { } } - static func scaledFont(for style: TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> UIFont { + @MainActor static func scaledFont(for style: TextStyle, compatibleWith traitCollection: UITraitCollection? = nil) -> UIFont { let fontMetrics = UIFontMetrics(forTextStyle: style.uiFontTextStyle) let scaledFont = fontMetrics.scaledFont(for: style.uiFont, compatibleWith: resolvedTraits(for: traitCollection)) switch (traitCollection, traitCollectionOverrideForTesting) { diff --git a/Tests/ThumbprintTests/Snapshot/Components/AlertBannerTest.swift b/Tests/ThumbprintTests/Snapshot/Components/AlertBannerTest.swift index 32d6b4d..9e050fe 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/AlertBannerTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/AlertBannerTest.swift @@ -2,7 +2,7 @@ import Thumbprint import UIKit class AlertBannerTest: SnapshotTestCase { - func testInfo() { + @MainActor func testInfo() { let alertBanner = Thumbprint.AlertBanner( theme: .info, message: "This is a sample message for an info banner.", @@ -13,7 +13,7 @@ class AlertBannerTest: SnapshotTestCase { verify(alertBanner: alertBanner) } - func testWarning() { + @MainActor func testWarning() { let alertBanner = Thumbprint.AlertBanner( theme: .warning, message: "This is a sample message for a warning banner.", @@ -24,7 +24,7 @@ class AlertBannerTest: SnapshotTestCase { verify(alertBanner: alertBanner) } - func testCaution() { + @MainActor func testCaution() { let alertBanner = Thumbprint.AlertBanner( theme: .caution, message: "This is a sample message for a caution banner.", @@ -35,7 +35,7 @@ class AlertBannerTest: SnapshotTestCase { verify(alertBanner: alertBanner) } - func testMaxHeight() { + @MainActor func testMaxHeight() { let alertBanner = Thumbprint.AlertBanner( theme: .info, message: "This is a sample message for an info banner.", @@ -49,7 +49,7 @@ class AlertBannerTest: SnapshotTestCase { verify(alertBanner: alertBanner) } - func testUpdate() { + @MainActor func testUpdate() { let alertBanner = Thumbprint.AlertBanner( theme: .info, message: "This is a sample message for an info banner.", @@ -61,7 +61,7 @@ class AlertBannerTest: SnapshotTestCase { verify(alertBanner: alertBanner) } - func verify(alertBanner: AlertBanner) { + @MainActor func verify(alertBanner: AlertBanner) { for widthToVerify in WindowSize.allPhones.map({ windowSize in windowSize.cgSize.width }) { verify( view: alertBanner, diff --git a/Tests/ThumbprintTests/Snapshot/Components/AvatarTest.swift b/Tests/ThumbprintTests/Snapshot/Components/AvatarTest.swift index fcf1d87..eb8536f 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/AvatarTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/AvatarTest.swift @@ -17,7 +17,7 @@ class AvatarTest: SnapshotTestCase { .xLarge, ] - func testInitialsUser() { + @MainActor func testInitialsUser() { let initials = [ "AYYYY", "BOOOOOOO", @@ -36,7 +36,7 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testImageUser() { + @MainActor func testImageUser() { let image = UIImage(named: "eric", in: Bundle.testing, compatibleWith: nil) @@ -49,7 +49,7 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testInitialsEntity() { + @MainActor func testInitialsEntity() { let initials = [ "AYYYY", "BOOOOOOO", @@ -68,7 +68,7 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testImageEntity() { + @MainActor func testImageEntity() { let image = UIImage(named: "eric", in: Bundle.testing, compatibleWith: nil) @@ -81,7 +81,7 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testOnlineEntity() { + @MainActor func testOnlineEntity() { let image = UIImage(named: "eric", in: Bundle.testing, compatibleWith: nil) @@ -95,7 +95,7 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testOnlineUser() { + @MainActor func testOnlineUser() { let image = UIImage(named: "eric", in: Bundle.testing, compatibleWith: nil) @@ -109,13 +109,13 @@ class AvatarTest: SnapshotTestCase { verifyViews(views: views) } - func testInitialization() { + @MainActor func testInitialization() { let userAvatar = UserAvatar(size: .medium, initials: "DR", name: "Daniel Roth", isOnline: false) let entityAvatar = EntityAvatar(size: .medium, initials: "D", name: "Daniel Roth", isOnline: true) verifyViews(views: [userAvatar, entityAvatar]) } - func verifyViews(views: [AvatarView]) { + @MainActor func verifyViews(views: [AvatarView]) { let stackView = UIStackView() stackView.axis = .vertical stackView.alignment = .leading diff --git a/Tests/ThumbprintTests/Snapshot/Components/ButtonRowTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ButtonRowTest.swift index e767278..8609de3 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ButtonRowTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ButtonRowTest.swift @@ -14,7 +14,7 @@ class ButtonRowTest: SnapshotTestCase { .minimal, ] - func testAll() { + @MainActor func testAll() { let buttonRow = ButtonRow(leftButton: Button(theme: .tertiary, adjustsFontForContentSizeCategory: false), rightButton: Button(adjustsFontForContentSizeCategory: false)) distributions.forEach { distribution in diff --git a/Tests/ThumbprintTests/Snapshot/Components/ButtonStackTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ButtonStackTest.swift index b9874ac..d16b089 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ButtonStackTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ButtonStackTest.swift @@ -2,14 +2,14 @@ import Thumbprint import UIKit class ButtonStackTest: SnapshotTestCase { - func testOneButton() { + @MainActor func testOneButton() { let button1 = Button(adjustsFontForContentSizeCategory: false) button1.title = "Button 1" verify(ButtonStack(buttons: [button1])) } - func testTwoButtons() { + @MainActor func testTwoButtons() { let button1 = Button(adjustsFontForContentSizeCategory: false) button1.title = "Button 1" @@ -19,7 +19,7 @@ class ButtonStackTest: SnapshotTestCase { verify(ButtonStack(buttons: [button1, button2])) } - func testThreeButtons() { + @MainActor func testThreeButtons() { let button1 = Button(adjustsFontForContentSizeCategory: false) button1.title = "Button 1" @@ -32,7 +32,7 @@ class ButtonStackTest: SnapshotTestCase { verify(ButtonStack(buttons: [button1, button2, button3])) } - func verify(_ buttonStack: ButtonStack, file: StaticString = #filePath, line: UInt = #line) { + @MainActor func verify(_ buttonStack: ButtonStack, file: StaticString = #filePath, line: UInt = #line) { verify(view: buttonStack, identifier: "\(buttonStack.arrangedSubviews.count)buttons", contentSizeCategories: [.unspecified], diff --git a/Tests/ThumbprintTests/Snapshot/Components/ButtonTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ButtonTest.swift index e5d5b2c..a11462a 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ButtonTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ButtonTest.swift @@ -32,12 +32,12 @@ class ButtonTest: SnapshotTestCase { super.tearDown() } - func testThemes() { + @MainActor func testThemes() { themes.forEach { themeIdentifier, buttonConfig in icons.forEach { iconIdentifier, iconConfig in let size = WindowSize.intrinsic - func buttonMaker(postfix: String?) -> Button { + @MainActor func buttonMaker(postfix: String?) -> Button { let button = Button(theme: buttonConfig.theme, size: buttonConfig.size) var title = "\(themeIdentifier) \(iconIdentifier)" if let postfix { @@ -87,7 +87,7 @@ class ButtonTest: SnapshotTestCase { } } - func testSizes() { + @MainActor func testSizes() { sizes.forEach { sizeIdentifier, buttonConfig in icons.forEach { iconIdentifier, iconConfig in button = Button(theme: buttonConfig.exampleTheme, size: buttonConfig.size) @@ -102,7 +102,7 @@ class ButtonTest: SnapshotTestCase { } } - func testStretchWidth() { + @MainActor func testStretchWidth() { button = Button(adjustsFontForContentSizeCategory: true) button.title = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium ornare magna et tristique." button.icon = .init(.leading, image: Icon.notificationAlertsInfoFilledMedium.image) diff --git a/Tests/ThumbprintTests/Snapshot/Components/CalendarPickerTest.swift b/Tests/ThumbprintTests/Snapshot/Components/CalendarPickerTest.swift index cf19330..febb31c 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/CalendarPickerTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/CalendarPickerTest.swift @@ -22,29 +22,29 @@ class CalendarPickerViewTest: SnapshotTestCase { super.tearDown() } - func testNoPreviousMonths() { + @MainActor func testNoPreviousMonths() { calendarPicker.previousMonthCount = 0 calendarPicker.additionalMonthCount = 1 verify() } - func testNoAdditionalMonths() { + @MainActor func testNoAdditionalMonths() { calendarPicker.previousMonthCount = 1 calendarPicker.additionalMonthCount = 0 verify() } - func testFixedCellHeight() { + @MainActor func testFixedCellHeight() { calendarPicker.cellHeightMode = .fixed(70) verify() } - func testGoToDate() { + @MainActor func testGoToDate() { calendarPicker.goToDate(Calendar.current.date(from: DateComponents(year: 2021, month: 1, day: 20))!, animated: false) verify() } - func testRecreateFigmaMock() { + @MainActor func testRecreateFigmaMock() { calendarPicker.selectedDates = [ calendar.date(from: DateComponents(year: 2020, month: 1, day: 10))!, ] @@ -63,7 +63,7 @@ class CalendarPickerViewTest: SnapshotTestCase { verify() } - func testMultipleSelection() { + @MainActor func testMultipleSelection() { calendarPicker.allowsMultipleSelection = true calendarPicker.selectedDates = [ calendar.date(from: DateComponents(year: 2020, month: 1, day: 4))!, @@ -75,12 +75,12 @@ class CalendarPickerViewTest: SnapshotTestCase { verify() } - func testFixedHeight() { + @MainActor func testFixedHeight() { calendarPicker.calendarHeightMode = .fixed verify() } - func testNonGregorianCalendar() { + @MainActor func testNonGregorianCalendar() { calendar = Calendar(identifier: .hebrew) calendar.locale = Locale(identifier: "he_IL") calendarPicker = TestCalendarPickerView(visibleDate: today, calendar: calendar) @@ -92,7 +92,7 @@ class CalendarPickerViewTest: SnapshotTestCase { verify(identifier: "indian") } - private func verify(identifier: String? = nil) { + @MainActor private func verify(identifier: String? = nil) { verify(view: calendarPicker, identifier: identifier, contentSizeCategories: [.unspecified]) diff --git a/Tests/ThumbprintTests/Snapshot/Components/CheckboxTest.swift b/Tests/ThumbprintTests/Snapshot/Components/CheckboxTest.swift index f209e90..a95d26a 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/CheckboxTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/CheckboxTest.swift @@ -20,83 +20,83 @@ class CheckboxTest: SnapshotTestCase { // MARK: - Checkbox - func testCheckboxEmpty() { + @MainActor func testCheckboxEmpty() { verifyCheckbox() } - func testCheckboxEmptyHighlighted() { + @MainActor func testCheckboxEmptyHighlighted() { checkbox.isHighlighted = true verifyCheckbox() } - func testCheckboxEmptyDisabled() { + @MainActor func testCheckboxEmptyDisabled() { checkbox.isEnabled = false verifyCheckbox() } - func testCheckboxEmptyError() { + @MainActor func testCheckboxEmptyError() { checkbox.hasError = true verifyCheckbox() } - func testCheckboxEmptyLarge() { + @MainActor func testCheckboxEmptyLarge() { checkbox.checkBoxSize = 80 verifyCheckbox() } - func testCheckboxChecked() { + @MainActor func testCheckboxChecked() { checkbox.isSelected = true verifyCheckbox() } - func testCheckboxCheckedHighlighted() { + @MainActor func testCheckboxCheckedHighlighted() { checkbox.isSelected = true checkbox.isHighlighted = true verifyCheckbox() } - func testCheckboxCheckedDisabled() { + @MainActor func testCheckboxCheckedDisabled() { checkbox.isSelected = true checkbox.isEnabled = false verifyCheckbox() } - func testCheckboxCheckedError() { + @MainActor func testCheckboxCheckedError() { checkbox.isSelected = true checkbox.hasError = true verifyCheckbox() } - func testCheckboxCheckedLarge() { + @MainActor func testCheckboxCheckedLarge() { checkbox.checkBoxSize = 80 checkbox.isSelected = true verifyCheckbox() } - func testCheckboxIntermediate() { + @MainActor func testCheckboxIntermediate() { checkbox.mark = .intermediate verifyCheckbox() } - func testCheckboxIntermediateDisabled() { + @MainActor func testCheckboxIntermediateDisabled() { checkbox.mark = .intermediate checkbox.isEnabled = false verifyCheckbox() } - func testCheckboxIntermediateHighlighted() { + @MainActor func testCheckboxIntermediateHighlighted() { checkbox.mark = .intermediate checkbox.isHighlighted = true verifyCheckbox() } - func testCheckboxIntermediateError() { + @MainActor func testCheckboxIntermediateError() { checkbox.mark = .intermediate checkbox.hasError = true verifyCheckbox() } - func testCheckboxIntermediateLarge() { + @MainActor func testCheckboxIntermediateLarge() { checkbox.checkBoxSize = 80 checkbox.mark = .intermediate verifyCheckbox() @@ -104,99 +104,99 @@ class CheckboxTest: SnapshotTestCase { // MARK: - LabelCheckbox - func testLabelCheckboxEmpty() { + @MainActor func testLabelCheckboxEmpty() { verifyLabelCheckbox() } - func testLabelCheckboxEmptyDisabled() { + @MainActor func testLabelCheckboxEmptyDisabled() { labeledCheckbox.isEnabled = false verifyLabelCheckbox() } - func testLabelCheckboxEmptyHighlighted() { + @MainActor func testLabelCheckboxEmptyHighlighted() { labeledCheckbox.isHighlighted = true verifyLabelCheckbox() } - func testLabelCheckboxEmptyError() { + @MainActor func testLabelCheckboxEmptyError() { labeledCheckbox.hasError = true verifyLabelCheckbox() } - func testLabelCheckboxEmptyLarge() { + @MainActor func testLabelCheckboxEmptyLarge() { labeledCheckbox.checkBoxSize = 80 verifyLabelCheckbox() } - func testLabelCheckboxChecked() { + @MainActor func testLabelCheckboxChecked() { labeledCheckbox.isSelected = true verifyLabelCheckbox() } - func testLabelCheckboxCheckedDisabled() { + @MainActor func testLabelCheckboxCheckedDisabled() { labeledCheckbox.isSelected = true labeledCheckbox.isEnabled = false verifyLabelCheckbox() } - func testLabelCheckboxCheckedHighlighted() { + @MainActor func testLabelCheckboxCheckedHighlighted() { labeledCheckbox.isSelected = true labeledCheckbox.isHighlighted = true verifyLabelCheckbox() } - func testLabelCheckboxCheckedError() { + @MainActor func testLabelCheckboxCheckedError() { labeledCheckbox.isSelected = true labeledCheckbox.hasError = true verifyLabelCheckbox() } - func testLabelCheckboxCheckedLarge() { + @MainActor func testLabelCheckboxCheckedLarge() { labeledCheckbox.checkBoxSize = 80 labeledCheckbox.isSelected = true verifyLabelCheckbox() } - func testLabelCheckboxIntermediate() { + @MainActor func testLabelCheckboxIntermediate() { labeledCheckbox.mark = .intermediate verifyLabelCheckbox() } - func testLabelCheckboxIntermediateDisabled() { + @MainActor func testLabelCheckboxIntermediateDisabled() { labeledCheckbox.mark = .intermediate labeledCheckbox.isEnabled = false verifyLabelCheckbox() } - func testLabelCheckboxIntermediateHighlighted() { + @MainActor func testLabelCheckboxIntermediateHighlighted() { labeledCheckbox.mark = .intermediate labeledCheckbox.isHighlighted = true verifyLabelCheckbox() } - func testLabelCheckboxIntermediateError() { + @MainActor func testLabelCheckboxIntermediateError() { labeledCheckbox.mark = .intermediate labeledCheckbox.hasError = true verifyLabelCheckbox() } - func testLabelCheckboxIntermediateLarge() { + @MainActor func testLabelCheckboxIntermediateLarge() { labeledCheckbox.checkBoxSize = 80 labeledCheckbox.mark = .intermediate verifyLabelCheckbox() } - func testLabelCheckboxContentLeft() { + @MainActor func testLabelCheckboxContentLeft() { labeledCheckbox.contentPlacement = .left verifyLabelCheckbox() } - func testLabelCheckboxContentInsets() { + @MainActor func testLabelCheckboxContentInsets() { labeledCheckbox.contentInsets = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40) verifyLabelCheckbox() } - func testLabelCheckboxMultilineText() { + @MainActor func testLabelCheckboxMultilineText() { labeledCheckbox.numberOfLines = 0 labeledCheckbox.text = "This is a checkbox label text that will spread out over multiple lines because this text is too big to fit on one line" verifyLabelCheckbox(limitedWidth: true) @@ -204,11 +204,11 @@ class CheckboxTest: SnapshotTestCase { // MARK: - Private - private func verifyCheckbox() { + @MainActor private func verifyCheckbox() { verify(view: checkbox, contentSizeCategories: [.large]) } - private func verifyLabelCheckbox(limitedWidth: Bool = false) { + @MainActor private func verifyLabelCheckbox(limitedWidth: Bool = false) { verify( view: labeledCheckbox, sizes: [limitedWidth ? .defaultWidthIntrinsicHeight : .intrinsic], diff --git a/Tests/ThumbprintTests/Snapshot/Components/DropdownTest.swift b/Tests/ThumbprintTests/Snapshot/Components/DropdownTest.swift index 050c876..41fe8e0 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/DropdownTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/DropdownTest.swift @@ -19,36 +19,36 @@ class DropdownTest: SnapshotTestCase { super.tearDown() } - func testDefaultPlaceholder() { + @MainActor func testDefaultPlaceholder() { verify() } - func testCustomPlaceholder() { + @MainActor func testCustomPlaceholder() { dropdown.placeholder = "Make a selection..." verify() } - func testHighlighted() { + @MainActor func testHighlighted() { dropdown.isHighlighted = true verify() } - func testErroroneous() { + @MainActor func testErroroneous() { dropdown.hasError = true verify() } - func testDisabled() { + @MainActor func testDisabled() { dropdown.isEnabled = false verify() } - func testSelect() { + @MainActor func testSelect() { dropdown.selectedIndex = 0 verify() } - private func verify() { + @MainActor private func verify() { let container = UIView() container.addSubview(dropdown) diff --git a/Tests/ThumbprintTests/Snapshot/Components/FilterChipTest.swift b/Tests/ThumbprintTests/Snapshot/Components/FilterChipTest.swift index 5848346..e529687 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/FilterChipTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/FilterChipTest.swift @@ -15,33 +15,33 @@ class FilterChipTest: SnapshotTestCase { super.tearDown() } - private func verifyChip(selected: Bool, highlighted: Bool) { + @MainActor private func verifyChip(selected: Bool, highlighted: Bool) { filterChip.isSelected = selected filterChip.isHighlighted = highlighted verify(view: filterChip) } - func testDefault() { + @MainActor func testDefault() { verifyChip(selected: false, highlighted: false) } - func testDefaultHighlighted() { + @MainActor func testDefaultHighlighted() { verifyChip(selected: false, highlighted: true) } - func testSelected() { + @MainActor func testSelected() { verifyChip(selected: true, highlighted: false) } - func testSelectedHighlighted() { + @MainActor func testSelectedHighlighted() { verifyChip(selected: true, highlighted: true) } /** Use this to produce the image to show in the Thumprint iOS Chip documentation */ - func testDocumentation() { + @MainActor func testDocumentation() { let stackView = UIStackView() stackView.axis = .vertical stackView.spacing = Space.two diff --git a/Tests/ThumbprintTests/Snapshot/Components/FooterTest.swift b/Tests/ThumbprintTests/Snapshot/Components/FooterTest.swift index 3a23e34..dc0c2e5 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/FooterTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/FooterTest.swift @@ -9,7 +9,7 @@ class FooterTest: SnapshotTestCase { "short-secondary": ("Etiam egestas, metus id dignissim ultrices, odio enim imperdiet est, placerat ullamcorper augue ligula sed odio.", "Title"), ] - func testSafeArea() { + @MainActor func testSafeArea() { let factory: () -> UIViewController = { let buttonRow = ButtonRow(leftButton: Button(theme: .tertiary, adjustsFontForContentSizeCategory: false), rightButton: Button(adjustsFontForContentSizeCategory: false)) buttonRow.leftButton.title = "Title" @@ -41,7 +41,7 @@ class FooterTest: SnapshotTestCase { contentSizeCategories: [.unspecified]) } - func testScreenWidths() { + @MainActor func testScreenWidths() { verify( viewControllerFactory: { let buttonRow = ButtonRow(leftButton: Button(theme: .tertiary, adjustsFontForContentSizeCategory: false), rightButton: Button(adjustsFontForContentSizeCategory: false)) @@ -67,7 +67,7 @@ class FooterTest: SnapshotTestCase { ) } - func testRegularSizeClass() { + @MainActor func testRegularSizeClass() { verify( viewControllerFactory: { let buttonRow = ButtonRow(leftButton: Button(theme: .tertiary, adjustsFontForContentSizeCategory: false), rightButton: Button(adjustsFontForContentSizeCategory: false)) @@ -102,7 +102,7 @@ class FooterTest: SnapshotTestCase { ) } - func testShowShadowByDefault() { + @MainActor func testShowShadowByDefault() { verify( viewControllerFactory: { let viewController = UIViewController(nibName: nil, bundle: nil) diff --git a/Tests/ThumbprintTests/Snapshot/Components/IconButtonTest.swift b/Tests/ThumbprintTests/Snapshot/Components/IconButtonTest.swift index 5c59b09..3d78e9a 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/IconButtonTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/IconButtonTest.swift @@ -7,7 +7,7 @@ class IconButtonTest: SnapshotTestCase { "dark": .dark, ] - func testIconButton() { + @MainActor func testIconButton() { let containerView = UIView() containerView.backgroundColor = Color.blue @@ -47,7 +47,7 @@ class IconButtonTest: SnapshotTestCase { } } - func testChangeIconSize() { + @MainActor func testChangeIconSize() { let iconButton = IconButton( icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add", @@ -62,7 +62,7 @@ class IconButtonTest: SnapshotTestCase { verify(view: iconButton, contentSizeCategories: [.unspecified]) } - func testAddInsetsToIconButton() { + @MainActor func testAddInsetsToIconButton() { let iconButton = IconButton( icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add", @@ -73,7 +73,7 @@ class IconButtonTest: SnapshotTestCase { verify(view: iconButton, contentSizeCategories: [.unspecified]) } - func testChangeIconAndTheme() { + @MainActor func testChangeIconAndTheme() { let iconButton = IconButton( icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add", diff --git a/Tests/ThumbprintTests/Snapshot/Components/IconFloatingActionButtonTest.swift b/Tests/ThumbprintTests/Snapshot/Components/IconFloatingActionButtonTest.swift index 56e08af..f86bccd 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/IconFloatingActionButtonTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/IconFloatingActionButtonTest.swift @@ -2,12 +2,12 @@ import Thumbprint import UIKit class IconFloatingActionButtonTest: SnapshotTestCase { - func testWithPrimaryTheme() { + @MainActor func testWithPrimaryTheme() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithSecondaryTheme() { + @MainActor func testWithSecondaryTheme() { let button = IconFloatingActionButton( icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action", @@ -16,13 +16,13 @@ class IconFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testIsHighlighted() { + @MainActor func testIsHighlighted() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.isHighlighted = true verify(view: button, contentSizeCategories: [.unspecified]) } - func testIsHighlightedSecondary() { + @MainActor func testIsHighlightedSecondary() { let button = IconFloatingActionButton( icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action", @@ -32,33 +32,33 @@ class IconFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeIcon() { + @MainActor func testChangeIcon() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.setIcon(Icon.notificationAlertsBlockedFilledMedium.image, accessibilityLabel: "Archive") verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeTheme() { + @MainActor func testChangeTheme() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.theme = .secondary verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeHighlighted() { + @MainActor func testChangeThemeHighlighted() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.theme = .secondary button.isHighlighted = true verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeAndBack() { + @MainActor func testChangeThemeAndBack() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.theme = .secondary button.theme = .primary verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeAndBackHighlighted() { + @MainActor func testChangeThemeAndBackHighlighted() { let button = IconFloatingActionButton(icon: Icon.notificationAlertsInfoFilledMedium.image, accessibilityLabel: "Add action") button.theme = .secondary button.theme = .primary diff --git a/Tests/ThumbprintTests/Snapshot/Components/NavigationBarTest.swift b/Tests/ThumbprintTests/Snapshot/Components/NavigationBarTest.swift index 088ba31..934b6ea 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/NavigationBarTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/NavigationBarTest.swift @@ -14,7 +14,7 @@ class NavigationBarTest: SnapshotTestCase { "light": .light, ] - func testAppearances() { + @MainActor func testAppearances() { appearances.forEach { let (appearanceIdentifier, appearance) = $0 @@ -34,7 +34,7 @@ class NavigationBarTest: SnapshotTestCase { } } - func verify(identifier: String?, file: StaticString = #file, line: UInt = #line, configure: (UINavigationBar) -> Void) { + @MainActor func verify(identifier: String?, file: StaticString = #file, line: UInt = #line, configure: (UINavigationBar) -> Void) { verify( viewControllerFactory: { let viewController = UIViewController() diff --git a/Tests/ThumbprintTests/Snapshot/Components/PillTest.swift b/Tests/ThumbprintTests/Snapshot/Components/PillTest.swift index b6a96d5..52983ad 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/PillTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/PillTest.swift @@ -20,7 +20,7 @@ class PillTest: SnapshotTestCase { super.tearDown() } - func testBlankPills() { + @MainActor func testBlankPills() { let defaultPill = Pill() stackView.addArrangedSubview(defaultPill) @@ -33,7 +33,7 @@ class PillTest: SnapshotTestCase { verify(view: stackView) } - func testPillsWithTextOnly() { + @MainActor func testPillsWithTextOnly() { let defaultPill = Pill() defaultPill.text = "Default" stackView.addArrangedSubview(defaultPill) @@ -48,7 +48,7 @@ class PillTest: SnapshotTestCase { verify(view: stackView) } - func testPillsWithIconAndText() { + @MainActor func testPillsWithIconAndText() { let defaultPill = Pill() defaultPill.text = "Default" defaultPill.image = Icon.notificationAlertsInfoFilledMedium.image @@ -66,7 +66,7 @@ class PillTest: SnapshotTestCase { } // Verifies that the pills look right when expanded beyond their content hugging. - func testPillsExpanded() { + @MainActor func testPillsExpanded() { stackView.alignment = .fill let defaultPill = Pill() defaultPill.text = "Default" @@ -89,7 +89,7 @@ class PillTest: SnapshotTestCase { // Verifies that the pills deal with horizontal compression below intrinsic content width gracefully. We'd // expect the contents to eventually use all space in the pill and then start clipping the label before the // icon. - func testPillsCompressed() { + @MainActor func testPillsCompressed() { let defaultPill = Pill() defaultPill.text = "Default" defaultPill.image = Icon.notificationAlertsInfoFilledMedium.image @@ -113,7 +113,7 @@ class PillTest: SnapshotTestCase { /** This one doubles as a way to produce the iamges for the Thumbprint documentation. */ - func testDocumentationPills() { + @MainActor func testDocumentationPills() { let documentationPills: [(title: String, icon: UIImage, theme: Pill.Theme)] = [ ("Green", Icon.notificationAlertsInfoFilledMedium.image, .green), ("Red", Icon.notificationAlertsInfoFilledMedium.image, .red), diff --git a/Tests/ThumbprintTests/Snapshot/Components/ShadowCardTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ShadowCardTest.swift index ed28233..833edb9 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ShadowCardTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ShadowCardTest.swift @@ -2,7 +2,7 @@ import UIKit class ShadowCardTest: SnapshotTestCase { - func testWhiteBox() { + @MainActor func testWhiteBox() { let shadowCard = ShadowCard() verify( view: shadowCard, @@ -11,7 +11,7 @@ class ShadowCardTest: SnapshotTestCase { ) } - func testHighlighted() { + @MainActor func testHighlighted() { let shadowCard = ShadowCard() shadowCard.isHighlighted = true verify( diff --git a/Tests/ThumbprintTests/Snapshot/Components/ShadowTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ShadowTest.swift index d75d8b4..a8ce368 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ShadowTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ShadowTest.swift @@ -2,7 +2,7 @@ import UIKit class ShadowTest: SnapshotTestCase { - func testRegularShadows() { + @MainActor func testRegularShadows() { let stackView = UIStackView() stackView.axis = .horizontal stackView.distribution = .fillEqually @@ -40,7 +40,7 @@ class ShadowTest: SnapshotTestCase { verify(view: stackView, contentSizeCategories: [.unspecified]) } - func testRoundedShadows() { + @MainActor func testRoundedShadows() { let stackView = UIStackView() stackView.axis = .horizontal stackView.distribution = .fillEqually diff --git a/Tests/ThumbprintTests/Snapshot/Components/TabBarTest.swift b/Tests/ThumbprintTests/Snapshot/Components/TabBarTest.swift index 22f3c87..63546fd 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/TabBarTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/TabBarTest.swift @@ -2,7 +2,7 @@ import Thumbprint import UIKit class TabBarTest: SnapshotTestCase { - func testAppearance() { + @MainActor func testAppearance() { let tabBar = UITabBar(frame: CGRect(origin: .zero, size: SnapshotTestCase.WindowSize.defaultWidthIntrinsicHeight.cgSize)) let items = [ UITabBarItem(title: "Left", image: Icon.notificationAlertsInfoFilledMedium.image, selectedImage: nil), diff --git a/Tests/ThumbprintTests/Snapshot/Components/TextAreaTest.swift b/Tests/ThumbprintTests/Snapshot/Components/TextAreaTest.swift index dc7d633..9df6791 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/TextAreaTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/TextAreaTest.swift @@ -15,18 +15,18 @@ class TextAreaTest: SnapshotTestCase { super.tearDown() } - func testDefaultState() { + @MainActor func testDefaultState() { verify() } - func testDefaultStateWithText() { + @MainActor func testDefaultStateWithText() { textArea.text = "This is a simple text that can cover multiple lines if the control is too small to fit everything on one line." verify() } // Disabled because hangs frequently under github actions // https://thumbtack.atlassian.net/browse/MINF-2392 - func testFirstResponderEmpty() { + @MainActor func testFirstResponderEmpty() { verify { self.textArea.becomeFirstResponder() } @@ -34,7 +34,7 @@ class TextAreaTest: SnapshotTestCase { // Disabled because hangs frequently under github actions // https://thumbtack.atlassian.net/browse/MINF-2392 - func testFirstResponderFilled() { + @MainActor func testFirstResponderFilled() { textArea.text = "Test." verify { @@ -42,46 +42,46 @@ class TextAreaTest: SnapshotTestCase { } } - func testHighlightedEmpty() { + @MainActor func testHighlightedEmpty() { textArea.isHighlighted = true verify() } - func testHighlightedFilled() { + @MainActor func testHighlightedFilled() { textArea.isHighlighted = true textArea.text = "Come up with something buzzworthy time vampire. To be inspired is to become creative, innovative and energized we want this philosophy to trickle down to all our stakeholders shotgun approach." verify() } - func testDisabledEmpty() { + @MainActor func testDisabledEmpty() { textArea.isEnabled = false verify() } - func testDisabledFilled() { + @MainActor func testDisabledFilled() { textArea.isEnabled = false textArea.text = "Blue money guerrilla marketing hard stop we need to future-proof this, nor criticality or low hanging fruit the last person we talked to said this would be ready." verify() } - func testErrorEmpty() { + @MainActor func testErrorEmpty() { textArea.hasError = true verify() } - func testErrorFilled() { + @MainActor func testErrorFilled() { textArea.hasError = true textArea.text = "Alert! Alert!" verify() } - func testErrorAndDisabled() { + @MainActor func testErrorAndDisabled() { textArea.hasError = true textArea.isEnabled = false textArea.text = "This should appear disabled" @@ -89,7 +89,7 @@ class TextAreaTest: SnapshotTestCase { verify() } - func testErrorAndSelected() { + @MainActor func testErrorAndSelected() { textArea.hasError = true textArea.isSelected = true textArea.text = "This should appear as error" @@ -97,7 +97,7 @@ class TextAreaTest: SnapshotTestCase { verify() } - private func verify(file: StaticString = #filePath, line: UInt = #line, setUp: (() -> Void)? = nil) { + @MainActor private func verify(file: StaticString = #filePath, line: UInt = #line, setUp: (() -> Void)? = nil) { verify(view: textArea, sizes: [.size(width: .defaultWidth, height: 400)], file: file, diff --git a/Tests/ThumbprintTests/Snapshot/Components/TextFloatingActionButtonTest.swift b/Tests/ThumbprintTests/Snapshot/Components/TextFloatingActionButtonTest.swift index d8a32ec..9aecd45 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/TextFloatingActionButtonTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/TextFloatingActionButtonTest.swift @@ -2,12 +2,12 @@ import Thumbprint import UIKit class TextFloatingActionButtonTest: SnapshotTestCase { - func testWithPrimaryTheme() { + @MainActor func testWithPrimaryTheme() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithPrimaryThemeAndImage() { + @MainActor func testWithPrimaryThemeAndImage() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image @@ -15,7 +15,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithPrimaryThemeImageAndShortText() { + @MainActor func testWithPrimaryThemeImageAndShortText() { let button = TextFloatingActionButton(text: "Hey", accessibilityLabel: "Hey") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image @@ -23,7 +23,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithSecondaryTheme() { + @MainActor func testWithSecondaryTheme() { let button = TextFloatingActionButton( text: "Floating action button", accessibilityLabel: "Floating action button", @@ -32,7 +32,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithSecondaryThemeAndImage() { + @MainActor func testWithSecondaryThemeAndImage() { let button = TextFloatingActionButton( text: "Floating action button", accessibilityLabel: "Floating action button", @@ -44,7 +44,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testWithSecondaryThemeImageAndShortText() { + @MainActor func testWithSecondaryThemeImageAndShortText() { let button = TextFloatingActionButton( text: "Hey", accessibilityLabel: "Hey", @@ -56,13 +56,13 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testIsHighlighted() { + @MainActor func testIsHighlighted() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") button.isHighlighted = true verify(view: button, contentSizeCategories: [.unspecified]) } - func testIsHighlightedSecondary() { + @MainActor func testIsHighlightedSecondary() { let button = TextFloatingActionButton( text: "Floating action button", accessibilityLabel: "Floating action button", @@ -72,7 +72,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeTheme() { + @MainActor func testChangeTheme() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image @@ -81,7 +81,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeHighlighted() { + @MainActor func testChangeThemeHighlighted() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image @@ -91,7 +91,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeAndBack() { + @MainActor func testChangeThemeAndBack() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image @@ -101,7 +101,7 @@ class TextFloatingActionButtonTest: SnapshotTestCase { verify(view: button, contentSizeCategories: [.unspecified]) } - func testChangeThemeAndBackHighlighted() { + @MainActor func testChangeThemeAndBackHighlighted() { let button = TextFloatingActionButton(text: "Floating action button", accessibilityLabel: "Floating action button") let imageView = UIImageView() imageView.image = Icon.notificationAlertsInfoFilledMedium.image diff --git a/Tests/ThumbprintTests/Snapshot/Components/TextInputTest.swift b/Tests/ThumbprintTests/Snapshot/Components/TextInputTest.swift index 20cc895..d6791f8 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/TextInputTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/TextInputTest.swift @@ -18,63 +18,63 @@ class TextInputTest: SnapshotTestCase { super.tearDown() } - func testDefaultState() { + @MainActor func testDefaultState() { verify() } - func testSelectedEmpty() { + @MainActor func testSelectedEmpty() { textInput.isSelected = true verify() } - func testSelectedFilled() { + @MainActor func testSelectedFilled() { textInput.isSelected = true textInput.text = "Me first!" verify() } - func testHighlightedEmpty() { + @MainActor func testHighlightedEmpty() { textInput.isHighlighted = true verify() } - func testHighlightedFilled() { + @MainActor func testHighlightedFilled() { textInput.isHighlighted = true textInput.text = "I am so highlighted right now" verify() } - func testDisabledEmpty() { + @MainActor func testDisabledEmpty() { textInput.isEnabled = false verify() } - func testDisabledFilled() { + @MainActor func testDisabledFilled() { textInput.isEnabled = false textInput.text = "When I was your age..." verify() } - func testErrorEmpty() { + @MainActor func testErrorEmpty() { textInput.hasError = true verify() } - func testErrorFilled() { + @MainActor func testErrorFilled() { textInput.hasError = true textInput.text = "Alert! Alert!" verify() } - func testErrorAndDisabled() { + @MainActor func testErrorAndDisabled() { textInput.hasError = true textInput.isEnabled = false textInput.text = "This should appear disabled" @@ -82,7 +82,7 @@ class TextInputTest: SnapshotTestCase { verify() } - func testErrorAndSelected() { + @MainActor func testErrorAndSelected() { textInput.hasError = true textInput.isSelected = true textInput.text = "This should appear as error" @@ -90,7 +90,7 @@ class TextInputTest: SnapshotTestCase { verify() } - func testLeftView() { + @MainActor func testLeftView() { let leftView = UIButton(type: .system) leftView.setTitle("left", for: .normal) @@ -102,7 +102,7 @@ class TextInputTest: SnapshotTestCase { verify() } - func testRightView() { + @MainActor func testRightView() { let rightView = UIButton(type: .system) rightView.setTitle("right", for: .normal) @@ -114,7 +114,7 @@ class TextInputTest: SnapshotTestCase { verify() } - func testLeftAndRightView() { + @MainActor func testLeftAndRightView() { let leftView = UIButton(type: .system) leftView.setTitle("left", for: .normal) @@ -132,7 +132,7 @@ class TextInputTest: SnapshotTestCase { verify() } - private func verify(file: StaticString = #filePath, line: UInt = #line) { + @MainActor private func verify(file: StaticString = #filePath, line: UInt = #line) { verify( view: textInput, sizes: [.defaultWidthIntrinsicHeight], diff --git a/Tests/ThumbprintTests/Snapshot/Components/ToastTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ToastTest.swift index 369fe8c..aee2cfe 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ToastTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ToastTest.swift @@ -2,43 +2,43 @@ import UIKit class ToastTest: SnapshotTestCase { - func testDefaultTheme() { + @MainActor func testDefaultTheme() { let toast = Toast(message: "This is a message?", theme: Toast.Theme.default(), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testAlertTheme() { + @MainActor func testAlertTheme() { let toast = Toast(message: "This is a message?", theme: Toast.Theme.alert(), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testInfoTheme() { + @MainActor func testInfoTheme() { let toast = Toast(message: "This is a message?", theme: Toast.Theme.info(), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testCautionTheme() { + @MainActor func testCautionTheme() { let toast = Toast(message: "This is a message?", theme: Toast.Theme.caution(), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testSuccessTheme() { + @MainActor func testSuccessTheme() { // NOTE WE SET NO IMAGE HERE BECAUSE THE DEFAULT IMAGE ISNT BUNDLED let toast = Toast(message: "This is a message?", theme: Toast.Theme.success(nil), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testCustomImage() { + @MainActor func testCustomImage() { let toast = Toast(message: "This is a message?", theme: Toast.Theme.success(Icon.contentActionsAddMedium), action: Toast.Action(text: "Take Action", handler: {})) verify(toast: toast) } - func testLongText() { + @MainActor func testLongText() { let toast = Toast(message: "This is a very long message that should probably wrap to fit multiple lines, except on iPad.", theme: Toast.Theme.success(Icon.contentActionsAddMedium), action: Toast.Action(text: "Hyperlink Text", handler: {})) verify(toast: toast) } - private func verify(toast: Toast) { + @MainActor private func verify(toast: Toast) { verify( viewFactory: { toast.showToast(animated: false, completion: nil) diff --git a/Tests/ThumbprintTests/Snapshot/Components/ToggleChipTest.swift b/Tests/ThumbprintTests/Snapshot/Components/ToggleChipTest.swift index b153301..dbd07d3 100644 --- a/Tests/ThumbprintTests/Snapshot/Components/ToggleChipTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Components/ToggleChipTest.swift @@ -15,33 +15,33 @@ class ToggleChipTest: SnapshotTestCase { super.tearDown() } - private func verifyChip(selected: Bool, highlighted: Bool) { + @MainActor private func verifyChip(selected: Bool, highlighted: Bool) { toggleChip.isSelected = selected toggleChip.isHighlighted = highlighted verify(view: toggleChip) } - func testDefault() { + @MainActor func testDefault() { verifyChip(selected: false, highlighted: false) } - func testDefaultHighlighted() { + @MainActor func testDefaultHighlighted() { verifyChip(selected: false, highlighted: true) } - func testSelected() { + @MainActor func testSelected() { verifyChip(selected: true, highlighted: false) } - func testSelectedHighlighted() { + @MainActor func testSelectedHighlighted() { verifyChip(selected: true, highlighted: true) } /** Use this to produce the image to show in the Thumprint iOS Chip documentation */ - func testDocumentation() { + @MainActor func testDocumentation() { let stackView = UIStackView() stackView.axis = .vertical stackView.spacing = Space.two diff --git a/Tests/ThumbprintTests/Snapshot/Layouts/CarouselLayoutTest.swift b/Tests/ThumbprintTests/Snapshot/Layouts/CarouselLayoutTest.swift index 537eeb9..f0e234e 100644 --- a/Tests/ThumbprintTests/Snapshot/Layouts/CarouselLayoutTest.swift +++ b/Tests/ThumbprintTests/Snapshot/Layouts/CarouselLayoutTest.swift @@ -2,7 +2,7 @@ import UIKit class CarouselLayoutTest: SnapshotTestCase { - func testLayout() { + @MainActor func testLayout() { let carouselLayout = CarouselLayout() carouselLayout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 0, right: 0) carouselLayout.itemSize = CGSize(width: 100, height: 150) diff --git a/Tests/ThumbprintTests/Snapshot/Shared/SnapshotTestCase.swift b/Tests/ThumbprintTests/Snapshot/Shared/SnapshotTestCase.swift index 723c3bd..9fffdc9 100644 --- a/Tests/ThumbprintTests/Snapshot/Shared/SnapshotTestCase.swift +++ b/Tests/ThumbprintTests/Snapshot/Shared/SnapshotTestCase.swift @@ -37,7 +37,7 @@ open class SnapshotTestCase: XCTestCase { } } - public func cgSize(compatibleWith traitCollection: UITraitCollection) -> CGSize { + @MainActor public func cgSize(compatibleWith traitCollection: UITraitCollection) -> CGSize { switch self { case let .size(width, height, true): CGSize( @@ -100,7 +100,7 @@ open class SnapshotTestCase: XCTestCase { assert(UIDevice.current.systemVersion == expectedSystemVersion, "Snapshot tests should be run on iOS \(expectedSystemVersion).") } - public func verify(viewFactory: () -> T, + @MainActor public func verify(viewFactory: () -> T, identifier: String? = nil, useNavigationController: Bool = false, sizes: [WindowSize] = [.intrinsic], @@ -152,7 +152,7 @@ open class SnapshotTestCase: XCTestCase { ) } - public func verify(view: UIView, + @MainActor public func verify(view: UIView, identifier: String? = nil, useNavigationController: Bool = false, sizes: [WindowSize] = [.intrinsic], @@ -202,7 +202,7 @@ open class SnapshotTestCase: XCTestCase { ) } - public func verify(viewControllerFactory: () -> T, + @MainActor public func verify(viewControllerFactory: () -> T, identifier: String? = nil, useNavigationController: Bool = false, sizes: [WindowSize] = .allPhones, @@ -232,7 +232,7 @@ open class SnapshotTestCase: XCTestCase { setUp: setUp) } - public func verify(modalViewControllerFactory: @escaping () -> UIViewController, + @MainActor public func verify(modalViewControllerFactory: @escaping () -> UIViewController, identifier: String? = nil, sizes: [WindowSize] = .allPhones, safeArea: UIEdgeInsets = .zero, @@ -282,7 +282,7 @@ open class SnapshotTestCase: XCTestCase { - Parameter verifyLayoutAmbiguity: Whether to run the layout ambiguity verifier. Some custom layouts will trigger it no matter what and some older logic may be impractical to fix in which cases turning it off is recommended. */ - public func verify( + @MainActor public func verify( scrollView: UIScrollView, identifier: String? = nil, verticalPadding: CGFloat = 0.0, @@ -342,7 +342,7 @@ open class SnapshotTestCase: XCTestCase { // MARK: - Private - private func verifyPrivate(viewControllerFactory: () -> T, // swiftlint:disable:this function_parameter_count + @MainActor private func verifyPrivate(viewControllerFactory: () -> T, // swiftlint:disable:this function_parameter_count identifier: String?, useNavigationController: Bool, sizes: [WindowSize],