Fix crash when frames not preloaded in time.
This commit is contained in:
parent
aa2e6a11c5
commit
79f01b02ad
@ -20,6 +20,12 @@ class GifuTests: XCTestCase {
|
|||||||
XCTAssertTrue(animator.isAnimatable)
|
XCTAssertTrue(animator.isAnimatable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testCurrentFrame() {
|
||||||
|
XCTAssertEqual(animator.currentFrameIndex, 0)
|
||||||
|
XCTAssertEqual(animator.currentFrameDuration, NSTimeInterval.infinity)
|
||||||
|
XCTAssertNil(animator.currentFrameImage)
|
||||||
|
}
|
||||||
|
|
||||||
func testFramePreload() {
|
func testFramePreload() {
|
||||||
let expectation = expectationWithDescription("frameDuration")
|
let expectation = expectationWithDescription("frameDuration")
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class Animator {
|
|||||||
/// - parameter index: The index of the duration.
|
/// - parameter index: The index of the duration.
|
||||||
/// - returns: The duration of the given frame.
|
/// - returns: The duration of the given frame.
|
||||||
func durationAtIndex(index: Int) -> NSTimeInterval {
|
func durationAtIndex(index: Int) -> NSTimeInterval {
|
||||||
return animatedFrames[index].duration
|
return animatedFrames[safe: index]?.duration ?? NSTimeInterval.infinity
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether the frame should be changed and calls a handler with the results.
|
/// Checks whether the frame should be changed and calls a handler with the results.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user