/core/externals/update-engine/externals/google-toolbox-for-mac/AppKit/GTMKeyValueAnimationTest.m

http://macfuse.googlecode.com/ · 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. #import "GTMSenTestCase.h"
  19. #import "GTMKeyValueAnimation.h"
  20. #import "GTMFoundationUnitTestingUtilities.h"
  21. @interface GTMKeyValueAnimationTest : GTMTestCase <NSAnimationDelegate> {
  22. @private
  23. GTMUnitTestingBooleanRunLoopContext *context_;
  24. BOOL shouldStartHit_;
  25. }
  26. @end
  27. @implementation GTMKeyValueAnimationTest
  28. - (void)testAnimation {
  29. shouldStartHit_ = NO;
  30. GTMKeyValueAnimation *anim =
  31. [[[GTMKeyValueAnimation alloc] initWithTarget:self
  32. keyPath:@"oggle"] autorelease];
  33. [anim setDelegate:self];
  34. [anim startAnimation];
  35. context_ = [GTMUnitTestingBooleanRunLoopContext context];
  36. [[NSRunLoop currentRunLoop] gtm_runUpToSixtySecondsWithContext:context_];
  37. [anim stopAnimation];
  38. STAssertTrue([context_ shouldStop], @"Animation value never got set");
  39. STAssertTrue(shouldStartHit_, @"animationShouldStart not called");
  40. }
  41. - (BOOL)animationShouldStart:(NSAnimation*)animation {
  42. shouldStartHit_ = YES;
  43. return YES;
  44. }
  45. - (void)setOggle:(CGFloat)oggle {
  46. [context_ setShouldStop:YES];
  47. }
  48. @end