-
Notifications
You must be signed in to change notification settings - Fork 28
/
IFTTTLaunchImageTests.m
102 lines (75 loc) · 3.02 KB
/
IFTTTLaunchImageTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// IFTTTLaunchImageTests.m
// IFTTTLaunchImageTests
//
// Created by Jonathan Hersh on 1/7/15.
// Copyright (c) 2015 IFTTT. All rights reserved.
//
@import UIKit;
@import XCTest;
#import <FBSnapshotTestCase.h>
#import <UIImage+IFTTTLaunchImage.h>
#import <UIDevice+IFTTTLaunchImage.h>
#import <IFTTTSplashView.h>
#import <XCTest+MXGSynchronizeTest.h>
@interface IFTTTLaunchImageTests : FBSnapshotTestCase
@end
@implementation IFTTTLaunchImageTests
- (void)setUp {
[super setUp];
self.renderAsLayer = YES;
// self.recordMode = YES;
}
- (void)tearDown {
[super tearDown];
}
- (void)testLocatesDefaultLaunchImage {
UIImage *defaultImage = [UIImage IFTTTDefaultLaunchImage];
XCTAssertNotNil(defaultImage, @"Should have returned a default launch image");
XCTAssertTrue([defaultImage isKindOfClass:[UIImage class]], @"Should have returned an image");
XCTAssertFalse(CGSizeEqualToSize(defaultImage.size, CGSizeZero), @"Launch image should have a nonzero size");
}
- (void)testLaunchSnapshot {
UIImageView *launchImageView = [[UIImageView alloc] initWithImage:[UIImage IFTTTDefaultLaunchImage]];
FBSnapshotVerifyView(launchImageView, nil);
}
#pragma mark - Splash View
- (void)testSplashViewShowsImage {
[[IFTTTSplashView sharedSplash] showSplash];
FBSnapshotVerifyView([IFTTTSplashView sharedSplash], nil);
}
- (void)testSplashViewImageAccess {
UIImage *image = [UIImage IFTTTDefaultLaunchImage];
[[IFTTTSplashView sharedSplash] setImage:image];
XCTAssertEqualObjects([IFTTTSplashView sharedSplash].image, image, @"Images should be equal");
}
- (void)testSplashCustomViewAccess {
UIView *view = [UIView new];
[[IFTTTSplashView sharedSplash] setCustomView:view];
XCTAssertEqualObjects([IFTTTSplashView sharedSplash].customView, view, @"Views should be set and retrieved");
}
- (void)testSplashViewDismissalTypes {
for (NSNumber *dismissalType in @[ @(IFTTTSplashAnimationDrop),
@(IFTTTSplashAnimationFade),
@(IFTTTSplashAnimationGrowFade),
@(IFTTTSplashAnimationNone) ]) {
[[IFTTTSplashView sharedSplash] showSplash];
XCTAssertFalse([IFTTTSplashView sharedSplash].hidden, @"Splash should be visible");
[XCTest mxg_synchronizeTest:^(BOOL *finished) {
[[IFTTTSplashView sharedSplash] dismissSplashWithAnimation:[dismissalType unsignedIntegerValue]
completion:^
{
*finished = YES;
XCTAssertTrue([IFTTTSplashView sharedSplash].hidden, @"Should be hidden");
}];
}];
}
}
#pragma mark - UIDevice
- (void)testIsIPhone {
XCTAssertFalse([[UIDevice currentDevice] IFTTTDeviceIsiPad], @"This test should be run on iPhone");
}
- (void)testIsPortrait {
XCTAssertFalse([[UIDevice currentDevice] IFTTTDeviceIsLandscape], @"This test should be run in portrait");
}
@end