Last active
August 29, 2015 14:04
-
-
Save wearhere/8f876463a1e8e8020d78 to your computer and use it in GitHub Desktop.
Test a superclass can register instances of subclasses for Subliminal app hooks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Subliminal/Subliminal.h> | |
/// The superclass | |
@interface SLSelfRegisteringAppTarget : NSObject | |
@end | |
@implementation SLSelfRegisteringAppTarget | |
- (id)init { | |
self = [super init]; | |
if (self) { | |
[[SLTestController sharedTestController] registerTarget:self forAction:@selector(testAction)]; | |
} | |
return self; | |
} | |
- (void)dealloc { | |
[[SLTestController sharedTestController] deregisterTarget:self]; | |
} | |
- (NSNumber *)testAction { | |
return @YES; | |
} | |
@end | |
/// The subclass | |
@interface SLSelfRegisteringAppTargetSubclass : SLSelfRegisteringAppTarget | |
@end | |
@implementation SLSelfRegisteringAppTargetSubclass | |
@end | |
/// The test | |
@interface SubclassTargetTest : SLTest | |
@end | |
@implementation SubclassTargetTest { | |
SLSelfRegisteringAppTargetSubclass *_target; | |
} | |
- (void)setUpTest { | |
_target = [[SLSelfRegisteringAppTargetSubclass alloc] init]; | |
} | |
- (void)tearDownTest { | |
_target = nil; | |
} | |
- (void)testSubclassTarget { | |
SLAssertTrue(SLAskAppYesNo(testAction), | |
@"Superclass did not register subclass for action."); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment