Files
Sparkle/Tests/SUUpdaterTest.m
Zorg 578e78876c Separate SUUpdater delegate methods into different file
Also create SUUpdaterPrivate protocol to expose as little as possible to the internal update drivers. Ideally this would be minimized and not even exist at all, but I don't want to make the architectural and potential backwards-incompatible changes required to do that.
2016-12-25 18:25:42 -05:00

79 lines
1.9 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"
#import "SUUpdaterDelegate.h"
@interface SUUpdaterTest : XCTestCase <SUUpdaterDelegate>
@property (strong) NSOperationQueue *queue;
@property (strong) SUUpdater *updater;
@end
@implementation SUUpdaterTest
@synthesize queue;
@synthesize updater;
- (void)setUp
{
[super setUp];
self.queue = [[NSOperationQueue alloc] init];
self.updater = [[SUUpdater alloc] initForBundle:[NSBundle bundleForClass:[self class]]];
self.updater.delegate = self;
}
- (void)tearDown
{
self.updater = nil;
self.queue = nil;
[super tearDown];
}
- (NSString *)feedURLStringForUpdater:(SUUpdater *) __unused updater
{
return @"https://test.example.com";
}
- (void)testFeedURL
{
[self.updater feedURL]; // this WON'T throw
[self.queue addOperationWithBlock:^{
XCTAssertTrue(![NSThread isMainThread]);
@try {
[self.updater feedURL];
XCTFail(@"feedURL did not throw an exception when called on a secondary thread");
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
}];
[self.queue waitUntilAllOperationsAreFinished];
}
- (void)testSetTestFeedURL
{
[self.updater setFeedURL:[NSURL URLWithString:@""]]; // this WON'T throw
[self.queue addOperationWithBlock:^{
XCTAssertTrue(![NSThread isMainThread]);
@try {
[self.updater setFeedURL:[NSURL URLWithString:@""]];
XCTFail(@"setFeedURL: did not throw an exception when called on a secondary thread");
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
}];
[self.queue waitUntilAllOperationsAreFinished];
}
@end