aboutsummaryrefslogtreecommitdiff
path: root/AppKit
diff options
context:
space:
mode:
authorGravatar dmaclach <dmaclach@gmail.com>2018-11-12 07:58:27 -0800
committerGravatar GitHub <noreply@github.com>2018-11-12 07:58:27 -0800
commiteba02dc2256ac28b8d888c55fc8fba92cf499d05 (patch)
treed52739f4231c16aa735d568589cc92184017eccd /AppKit
parent3ae69bf66a2370005233316cca543b9446f85daa (diff)
Move GTMCarbonEvent over to XCTestExpectation (#188)
Diffstat (limited to 'AppKit')
-rw-r--r--AppKit/GTMCarbonEventTest.m33
1 files changed, 13 insertions, 20 deletions
diff --git a/AppKit/GTMCarbonEventTest.m b/AppKit/GTMCarbonEventTest.m
index ed18342..a9c6bf2 100644
--- a/AppKit/GTMCarbonEventTest.m
+++ b/AppKit/GTMCarbonEventTest.m
@@ -40,7 +40,7 @@
@interface GTMCarbonEventDispatcherHandlerTest : GTMTestCase {
@private
- GTMUnitTestingBooleanRunLoopContext *hotKeyHit_;
+ XCTestExpectation *hotKeyHitExpectation_;
}
@end
@@ -257,15 +257,6 @@ extern EventTargetRef GetApplicationEventTarget(void);
@implementation GTMCarbonEventDispatcherHandlerTest
-- (void)setUp {
- hotKeyHit_ = [[GTMUnitTestingBooleanRunLoopContext alloc] init];
-}
-
-- (void)tearDown {
- [hotKeyHit_ release];
- hotKeyHit_ = nil;
-}
-
- (void)testEventHandler {
GTMCarbonEventDispatcherHandler *dispatcher
= [GTMCarbonEventDispatcherHandler sharedEventDispatcherHandler];
@@ -274,12 +265,12 @@ extern EventTargetRef GetApplicationEventTarget(void);
- (void)hitHotKey:(GTMCarbonHotKey *)key {
XCTAssertEqualObjects([key userInfo], self);
- [hotKeyHit_ setShouldStop:YES];
+ [hotKeyHitExpectation_ fulfill];
}
- (void)hitExceptionalHotKey:(GTMCarbonHotKey *)key {
XCTAssertEqualObjects([key userInfo], self);
- [hotKeyHit_ setShouldStop:YES];
+ [hotKeyHitExpectation_ fulfill];
[NSException raise:@"foo" format:@"bar"];
}
@@ -309,11 +300,12 @@ extern EventTargetRef GetApplicationEventTarget(void);
XCTAssertNotNil(hotKey, @"Unable to create hotkey");
// Post the hotkey combo to the event queue. If everything is working
- // correctly hitHotKey: should get called, and hotKeyHit_ will be set for
- // us. We run the event loop for a set amount of time waiting for this to
- // happen.
+ // correctly hitHotKey: should get called, and hotKeyHitExpecatation_ will
+ // be set for us. We run the event loop for a set amount of time waiting for
+ // this to happen.
+ hotKeyHitExpectation_ = [self expectationWithDescription:@"hotKey"];
[GTMAppKitUnitTestingUtilities postTypeCharacterEvent:'g' modifiers:keyMods];
- XCTAssertTrue([NSApp gtm_runUpToSixtySecondsWithContext:hotKeyHit_]);
+ [self waitForExpectationsWithTimeout:60 handler:NULL];
[dispatcher unregisterHotKey:hotKey];
}
}
@@ -338,11 +330,12 @@ extern EventTargetRef GetApplicationEventTarget(void);
XCTAssertNotNil(hotKey, @"Unable to create hotkey");
// Post the hotkey combo to the event queue. If everything is working
- // correctly hitHotKey: should get called, and hotKeyHit_ will be set for
- // us. We run the event loop for a set amount of time waiting for this to
- // happen.
+ // correctly hitHotKey: should get called, and hotKeyHitExpecatation_ will
+ // be set for us. We run the event loop for a set amount of time waiting for
+ // this to happen.
+ hotKeyHitExpectation_ = [self expectationWithDescription:@"hotKey"];
[GTMAppKitUnitTestingUtilities postTypeCharacterEvent:'g' modifiers:keyMods];
- XCTAssertTrue([NSApp gtm_runUpToSixtySecondsWithContext:hotKeyHit_]);
+ [self waitForExpectationsWithTimeout:60 handler:NULL];
[dispatcher unregisterHotKey:hotKey];
}
}