Port passing Logic Test coverage to ARC

This commit is contained in:
Blake Watters
2012-09-26 11:35:16 -04:00
parent 39f78d2cac
commit d195ea873c
30 changed files with 249 additions and 295 deletions

View File

@@ -154,28 +154,27 @@
- (void)createBackgroundObjects
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
assertThatBool([NSThread isMainThread], equalToBool(NO));
@autoreleasepool {
assertThatBool([NSThread isMainThread], equalToBool(NO));
// Assert this is not the main thread
// Create a new array of objects in the background
RKObjectManager *objectManager = [RKTestFactory objectManager];
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];
objectManager.managedObjectStore = managedObjectStore;
NSArray *humans = [NSArray arrayWithObject:[NSEntityDescription entityForName:@"RKHuman" inManagedObjectContext:managedObjectStore.primaryManagedObjectContext]];
_dictionary = [[NSMutableDictionary dictionaryWithObject:humans forKey:@"humans"] retain];
NSMethodSignature *signature = [self methodSignatureForSelector:@selector(informDelegateWithDictionary:)];
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
invocation.privateQueueManagedObjectContext = _objectStore.primaryManagedObjectContext;
invocation.mainQueueManagedObjectContext = _objectStore.mainQueueManagedObjectContext;
[invocation retain];
[invocation setTarget:self];
[invocation setSelector:@selector(informDelegateWithDictionary:)];
[invocation setArgument:&_dictionary atIndex:2]; // NOTE: _cmd and self are 0 and 1
[invocation setManagedObjectKeyPaths:[NSSet setWithObject:@"humans"] forArgument:2];
[invocation invokeOnMainThread];
// Assert this is not the main thread
// Create a new array of objects in the background
RKObjectManager *objectManager = [RKTestFactory objectManager];
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];
objectManager.managedObjectStore = managedObjectStore;
NSArray *humans = [NSArray arrayWithObject:[NSEntityDescription entityForName:@"RKHuman" inManagedObjectContext:managedObjectStore.primaryManagedObjectContext]];
_dictionary = [NSMutableDictionary dictionaryWithObject:humans forKey:@"humans"];
NSMethodSignature *signature = [self methodSignatureForSelector:@selector(informDelegateWithDictionary:)];
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
invocation.privateQueueManagedObjectContext = _objectStore.primaryManagedObjectContext;
invocation.mainQueueManagedObjectContext = _objectStore.mainQueueManagedObjectContext;
[invocation setTarget:self];
[invocation setSelector:@selector(informDelegateWithDictionary:)];
[invocation setArgument:&_dictionary atIndex:2]; // NOTE: _cmd and self are 0 and 1
[invocation setManagedObjectKeyPaths:[NSSet setWithObject:@"humans"] forArgument:2];
[invocation invokeOnMainThread];
[pool drain];
}
}
@end