Skip to content

Instantly share code, notes, and snippets.

@wearhere
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wearhere/8f876463a1e8e8020d78 to your computer and use it in GitHub Desktop.
Save wearhere/8f876463a1e8e8020d78 to your computer and use it in GitHub Desktop.
Test a superclass can register instances of subclasses for Subliminal app hooks.
#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