-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da7a0d9
commit e0f1290
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// SmoothLinearGradientTests.swift | ||
// SmoothGradientTests | ||
// | ||
// Copyright (c) 2023 Ramon Torres | ||
// | ||
// This file is part of SmoothGradient which is released under the MIT license. | ||
// See the LICENSE file in the root directory of this source tree for full details. | ||
// | ||
|
||
import XCTest | ||
import SwiftUI | ||
import SnapshotTesting | ||
import SmoothGradient | ||
|
||
#if os(iOS) || os(tvOS) | ||
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *) | ||
final class SmoothLinearGradientTests: XCTestCase { | ||
func test_horizontal() { | ||
verify( | ||
SmoothLinearGradient(from: .green, to: .blue, startPoint: .leading, endPoint: .trailing) | ||
) | ||
} | ||
|
||
func test_vertical() { | ||
verify( | ||
SmoothLinearGradient(from: .green, to: .blue, startPoint: .top, endPoint: .bottom) | ||
) | ||
} | ||
|
||
func test_diagonal() { | ||
verify( | ||
SmoothLinearGradient(from: .green, to: .blue, startPoint: .topLeading, endPoint: .bottomTrailing) | ||
) | ||
} | ||
|
||
func test_stops() { | ||
verify( | ||
SmoothLinearGradient( | ||
from: .init(color: .green, location: 0.2), | ||
to: .init(color: .red, location: 0.4), | ||
startPoint: .top, | ||
endPoint: .bottom | ||
) | ||
) | ||
} | ||
} | ||
|
||
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *) | ||
extension SmoothLinearGradientTests { | ||
func verify( | ||
_ gradient: SmoothLinearGradient, | ||
file: StaticString = #file, | ||
testName: String = #function, | ||
line: UInt = #line | ||
) { | ||
assertSnapshot( | ||
matching: gradient.frame(width: 256, height: 256), | ||
as: .image, | ||
file: file, | ||
testName: testName, | ||
line: line | ||
) | ||
} | ||
} | ||
#endif |
Binary file added
BIN
+641 KB
...SmoothGradientTests/__Snapshots__/SmoothLinearGradientTests/test_diagonal.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+672 KB
...oothGradientTests/__Snapshots__/SmoothLinearGradientTests/test_horizontal.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.5 KB
Tests/SmoothGradientTests/__Snapshots__/SmoothLinearGradientTests/test_stops.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+122 KB
...SmoothGradientTests/__Snapshots__/SmoothLinearGradientTests/test_vertical.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.