Merge pull request #1990 from spebbe/cpanimation_frame_rate

CPAnimation frame rate fixes.
This commit is contained in:
Antoine Mercadal committed 2013-11-18 16:20:29 -08:00
commit 985db21ed9
2 files changed
+50 -1

No files matched your search

+3 -1
View File
@@ -236,7 +236,9 @@ ACTUAL_FRAME_RATE = 0;
ACTUAL_FRAME_RATE = 0;
_lastTime = new Date();
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
var timerInterval = _frameRate <= 0.0 ? 0.0001 : 1.0/_frameRate;
_timer = [CPTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
}
/*
+47
View File
@@ -0,0 +1,47 @@
@import <AppKit/CPApplication.j>
@import <AppKit/CPAnimation.j>
[CPApplication sharedApplication];
@implementation CPAnimation (TestMethods)
{
}
- (CPTimer)timer
{
return _timer;
}
@end
@implementation CPAnimationTest : OJTestCase
{
}
- (void)testScheduleTimerWithIntervalBasedOnDefaultFrameRate
{
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
[animation startAnimation];
[self assert:1.0/60.0 equals:[[animation timer] timeInterval]];
}
- (void)testScheduleTimerWithIntervalBasedOnCustomFrameRate
{
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
[animation setFrameRate:30];
[animation startAnimation];
[self assert:1.0/30.0 equals:[[animation timer] timeInterval]];
}
- (void)testScheduleTimerWithIntervalBasedOnAsFastAsPossibleFrameRate
{
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
[animation setFrameRate:0];
[animation startAnimation];
[self assert:0.0001 equals:[[animation timer] timeInterval]];
}
@end