Files
Sparkle/Tests/SUUpdaterTest.m
T
Jake Petroules 444809da92 Force feedURL/setFeedURL to be called on the main thread.
This is better than relying solely on documentation.
2014-06-29 02:54:45 -04:00

80 lines
1.7 KiB
Objective-C

//
// SUUpdaterTest.m
// Sparkle
//
// Created by Jake Petroules on 2014-06-29.
// Copyright (c) 2014 Sparkle Project. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "SUConstants.h"
#import "SUUpdater.h"
@interface SUUpdaterTest : XCTestCase <SUUpdaterDelegate>
@end
@implementation SUUpdaterTest
{
NSOperationQueue *queue;
SUUpdater *updater;
}
- (void)setUp
{
[super setUp];
queue = [[NSOperationQueue alloc] init];
updater = [[SUUpdater alloc] init];
updater.delegate = self;
}
- (void)tearDown
{
[updater release];
updater = nil;
[queue release];
queue = nil;
[super tearDown];
}
- (NSString *)feedURLStringForUpdater:(SUUpdater *) __unused updater
{
return @"";
}
- (void)testFeedURL
{
[updater feedURL]; // this WON'T throw
[queue addOperationWithBlock:^{
XCTAssertTrue(![NSThread isMainThread]);
@try {
[updater feedURL];
XCTFail(@"feedURL did not throw an exception when called on a secondary thread");
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
}];
[queue waitUntilAllOperationsAreFinished];
}
- (void)setTestFeedURL
{
[updater setFeedURL:[NSURL URLWithString:@""]]; // this WON'T throw
[queue addOperationWithBlock:^{
XCTAssertTrue(![NSThread isMainThread]);
@try {
[updater setFeedURL:[NSURL URLWithString:@""]];
XCTFail(@"setFeedURL: did not throw an exception when called on a secondary thread");
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
}];
[queue waitUntilAllOperationsAreFinished];
}
@end