This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
/
FBSnapshotTestCaseDemoTests.m
80 lines (65 loc) · 2.55 KB
/
FBSnapshotTestCaseDemoTests.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
/*
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
@interface FBSnapshotTestCaseDemoTests : FBSnapshotTestCase
@end
@implementation FBSnapshotTestCaseDemoTests
- (void)setUp
{
[super setUp];
// Flip this to YES to record images in the reference image directory.
// You need to do this the first time you create a test and whenever you change the snapshotted views.
// Tests running in record mode will allways fail so that you know that you have to do something here before you commit.
self.recordMode = NO;
}
- (void)testViewSnapshot
{
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
redView.backgroundColor = [UIColor redColor];
FBSnapshotVerifyView(redView, nil);
FBSnapshotVerifyLayer(redView.layer, nil);
}
- (void)testViewSnapshotWithVisualEffects
{
if ([UIVisualEffect class]) {
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)];
redView.backgroundColor = [UIColor redColor];
visualEffectView.frame = CGRectMake(0, 0, 40, 40);
UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
parentView.backgroundColor = [UIColor whiteColor];
[parentView addSubview:redView];
[parentView addSubview:visualEffectView];
self.usesDrawViewHierarchyInRect = YES;
FBSnapshotVerifyView(parentView, nil);
}
}
- (void)testViewSnapshotWithUIAppearance
{
[[UISwitch appearance] setOnTintColor:[UIColor blueColor]];
[[UISwitch appearance] setThumbTintColor:[UIColor lightGrayColor]];
UISwitch *control = [[UISwitch alloc] init];
control.on = YES;
self.usesDrawViewHierarchyInRect = YES;
FBSnapshotVerifyView(control, nil);
}
- (void)testViewSnapshotWithDifferentBackgroundColorPerArchitecture
{
UIColor *color = FBSnapshotTestCaseIs64Bit() ? [UIColor magentaColor] : [UIColor cyanColor];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
view.backgroundColor = color;
FBSnapshotVerifyView(view, nil);
}
- (void)testViewSnapshotRecordedOnlyFor64BitArchitecture
{
UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
greenView.backgroundColor = [UIColor greenColor];
FBSnapshotVerifyView(greenView, nil);
}
@end