Merge branch 'feature/add-support-for-swiftui' into feature/adapt-uikit-animation-to-swiftui-variant

This commit is contained in:
Felix Mau
2022-04-29 18:49:04 +01:00
5 changed files with 129 additions and 120 deletions
@@ -30,14 +30,7 @@ final class GradientLoadingBarControllerTestCase: XCTestCase {
// When
gradientLoadingBarController.fadeIn(duration: 0)
let expectation = expectation(description: "Wait for view to appear.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
expectation.fulfill()
}
// Then
wait(for: [expectation], timeout: 1)
assertSnapshot(matching: rootViewController,
as: .image(drawHierarchyInKeyWindow: true, precision: Config.precision))
}
@@ -31,14 +31,7 @@ final class NotchGradientLoadingBarControllerTestCase: XCTestCase {
// When
notchGradientLoadingBarController.fadeIn(duration: 0)
let expectation = expectation(description: "Wait for view to appear.")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
expectation.fulfill()
}
// Then
wait(for: [expectation], timeout: 1)
assertSnapshot(matching: rootViewController,
as: .image(drawHierarchyInKeyWindow: true, precision: Config.precision))
}
@@ -26,6 +26,9 @@ final class GradientLoadingBarViewTestCase: XCTestCase {
static let gradientColors = [
#colorLiteral(red: 0.9490196078, green: 0.3215686275, blue: 0.431372549, alpha: 1), #colorLiteral(red: 0.9450980392, green: 0.4784313725, blue: 0.5921568627, alpha: 1), #colorLiteral(red: 0.9529411765, green: 0.737254902, blue: 0.7843137255, alpha: 1), #colorLiteral(red: 0.4274509804, green: 0.8666666667, blue: 0.9490196078, alpha: 1), #colorLiteral(red: 0.7568627451, green: 0.9411764706, blue: 0.9568627451, alpha: 1),
].map(Color.init)
/// The percentage of pixels that must match.
static let precision: Float = 0.98
}
// MARK: - Test cases
@@ -36,7 +39,7 @@ final class GradientLoadingBarViewTestCase: XCTestCase {
.frame(width: Config.frame.width, height: Config.frame.height)
// Then
assertSnapshot(matching: gradientLoadingBarView, as: .image)
assertSnapshot(matching: gradientLoadingBarView, as: .image(precision: Config.precision))
}
func test_gradientLoadingBarView_shouldContainCorrectCustomColors() {
@@ -45,6 +48,6 @@ final class GradientLoadingBarViewTestCase: XCTestCase {
.frame(width: Config.frame.width, height: Config.frame.height)
// Then
assertSnapshot(matching: gradientLoadingBarView, as: .image)
assertSnapshot(matching: gradientLoadingBarView, as: .image(precision: Config.precision))
}
}