diff --git a/GifuTests/GifuTests.swift b/GifuTests/GifuTests.swift index 46c0e54..86fb9bd 100644 --- a/GifuTests/GifuTests.swift +++ b/GifuTests/GifuTests.swift @@ -20,6 +20,12 @@ class GifuTests: XCTestCase { XCTAssertTrue(animator.isAnimatable) } + func testCurrentFrame() { + XCTAssertEqual(animator.currentFrameIndex, 0) + XCTAssertEqual(animator.currentFrameDuration, NSTimeInterval.infinity) + XCTAssertNil(animator.currentFrameImage) + } + func testFramePreload() { let expectation = expectationWithDescription("frameDuration") diff --git a/Source/Animator.swift b/Source/Animator.swift index f58054e..014a79f 100644 --- a/Source/Animator.swift +++ b/Source/Animator.swift @@ -92,7 +92,7 @@ class Animator { /// - parameter index: The index of the duration. /// - returns: The duration of the given frame. 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.