From c38a238b32e0e9a96d9a36d65f289ce3316008dc Mon Sep 17 00:00:00 2001 From: dmaclach Date: Mon, 12 Nov 2018 07:57:33 -0800 Subject: Move animation over to XCTestExpectation (#187) --- AppKit/GTMKeyValueAnimationTest.m | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/AppKit/GTMKeyValueAnimationTest.m b/AppKit/GTMKeyValueAnimationTest.m index aef262b..dd592e4 100644 --- a/AppKit/GTMKeyValueAnimationTest.m +++ b/AppKit/GTMKeyValueAnimationTest.m @@ -18,38 +18,37 @@ #import "GTMSenTestCase.h" #import "GTMKeyValueAnimation.h" -#import "GTMFoundationUnitTestingUtilities.h" @interface GTMKeyValueAnimationTest : GTMTestCase { @private - GTMUnitTestingBooleanRunLoopContext *context_; - BOOL shouldStartHit_; + XCTestExpectation *oggleExpectation_; + XCTestExpectation *shouldStartExpectation_; } @end @implementation GTMKeyValueAnimationTest - (void)testAnimation { - shouldStartHit_ = NO; GTMKeyValueAnimation *anim = [[[GTMKeyValueAnimation alloc] initWithTarget:self keyPath:@"oggle"] autorelease]; + oggleExpectation_ = [self expectationWithDescription:@"oggle"]; + // We are going to get called multiple times. + oggleExpectation_.assertForOverFulfill = NO; + shouldStartExpectation_ = [self expectationWithDescription:@"shouldStart"]; [anim setDelegate:self]; [anim startAnimation]; - context_ = [GTMUnitTestingBooleanRunLoopContext context]; - [[NSRunLoop currentRunLoop] gtm_runUpToSixtySecondsWithContext:context_]; + [self waitForExpectationsWithTimeout:60 handler:NULL]; [anim stopAnimation]; - XCTAssertTrue([context_ shouldStop], @"Animation value never got set"); - XCTAssertTrue(shouldStartHit_, @"animationShouldStart not called"); } - (BOOL)animationShouldStart:(NSAnimation*)animation { - shouldStartHit_ = YES; + [shouldStartExpectation_ fulfill]; return YES; } - (void)setOggle:(CGFloat)oggle { - [context_ setShouldStop:YES]; + [oggleExpectation_ fulfill]; } @end -- cgit v1.2.3