/core/externals/update-engine/externals/google-toolbox-for-mac/AppKit/GTMKeyValueAnimationTest.m
Objective C | 55 lines | 31 code | 7 blank | 17 comment | 0 complexity | e5d9f23840bb7788fc2ad6080412aad4 MD5 | raw file
1// 2// GTMKeyValueAnimationTest.m 3// 4// Copyright 2011 Google Inc. 5// 6// Licensed under the Apache License, Version 2.0 (the "License"); you may not 7// use this file except in compliance with the License. You may obtain a copy 8// of the License at 9// 10// http://www.apache.org/licenses/LICENSE-2.0 11// 12// Unless required by applicable law or agreed to in writing, software 13// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15// License for the specific language governing permissions and limitations under 16// the License. 17// 18 19#import "GTMSenTestCase.h" 20#import "GTMKeyValueAnimation.h" 21#import "GTMFoundationUnitTestingUtilities.h" 22 23@interface GTMKeyValueAnimationTest : GTMTestCase <NSAnimationDelegate> { 24 @private 25 GTMUnitTestingBooleanRunLoopContext *context_; 26 BOOL shouldStartHit_; 27} 28@end 29 30@implementation GTMKeyValueAnimationTest 31 32- (void)testAnimation { 33 shouldStartHit_ = NO; 34 GTMKeyValueAnimation *anim = 35 [[[GTMKeyValueAnimation alloc] initWithTarget:self 36 keyPath:@"oggle"] autorelease]; 37 [anim setDelegate:self]; 38 [anim startAnimation]; 39 context_ = [GTMUnitTestingBooleanRunLoopContext context]; 40 [[NSRunLoop currentRunLoop] gtm_runUpToSixtySecondsWithContext:context_]; 41 [anim stopAnimation]; 42 STAssertTrue([context_ shouldStop], @"Animation value never got set"); 43 STAssertTrue(shouldStartHit_, @"animationShouldStart not called"); 44} 45 46- (BOOL)animationShouldStart:(NSAnimation*)animation { 47 shouldStartHit_ = YES; 48 return YES; 49} 50 51- (void)setOggle:(CGFloat)oggle { 52 [context_ setShouldStop:YES]; 53} 54 55@end