Skip to content

Commit

Permalink
spotlight
Browse files Browse the repository at this point in the history
  • Loading branch information
keller committed Mar 1, 2018
1 parent 856a020 commit 7a4c911
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions xkcd/xkcdTests/xkcdTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
#import "NSString+StripTags.h"
#import "NSString+XKCDImageUrl.h"
#import "ShortcutsManager.h"
#import "SpotlightManager.h"
#import "TodayViewManager.h"
#import "UIColor+XKCD.h"
#import "UIImage+AsyncImage.h"
#import "UIImage+XKCD.h"
#import "UIStoryboard+XKCD.h"
#import "XKCD.h"

@import CoreSpotlight;
@import XCTest;

@interface xkcdTests : XCTestCase
Expand Down Expand Up @@ -181,6 +183,27 @@ - (void)testShortcuts {
XCTAssertNotNil([shortcutsManager launchObjectFromLaunchOptions:@{UIApplicationLaunchOptionsShortcutItemKey:@{}}]);
}

#pragma mark - SpotlightManager

- (void)testSpotlight {
SpotlightManager *spotlightManager = [SpotlightManager sharedManager];
XCTAssertNotNil(spotlightManager);

XCTAssertNil([spotlightManager indexWithLaunchObject:@"not an NSUserActivity"]);
XCTAssertNil([spotlightManager indexWithLaunchObject:nil]);

NSUserActivity *unsupportedActivity = [[NSUserActivity alloc] initWithActivityType:@"unsupported"];
XCTAssertNil([spotlightManager indexWithLaunchObject:unsupportedActivity]);

NSUserActivity *searchableActivity = [[NSUserActivity alloc] initWithActivityType:CSSearchableItemActionType];
searchableActivity.userInfo = @{CSSearchableItemActivityIdentifier:@1234};
XCTAssertEqualObjects([spotlightManager indexWithLaunchObject:searchableActivity], @1234);

XCTAssertNil([spotlightManager launchObjectFromLaunchOptions:nil]);
XCTAssertNil([spotlightManager launchObjectFromLaunchOptions:@{}]);
XCTAssertNotNil([spotlightManager launchObjectFromLaunchOptions:@{UIApplicationLaunchOptionsUserActivityDictionaryKey:@{@"activity": searchableActivity}}]);
}

#pragma mark - TodayViewManager

- (void)testTodayViewManager {
Expand Down

0 comments on commit 7a4c911

Please sign in to comment.