-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathUIImage+ASConvenienceTests.mm
68 lines (58 loc) · 2.88 KB
/
UIImage+ASConvenienceTests.mm
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
//
// UIImage+ASConvenienceTests.m
// AsyncDisplayKitTests
//
// Created by Vladimir Solomenchuk on 5/22/20.
// Copyright © 2020 Pinterest. All rights reserved.
//
#import <AsyncDisplayKit/ASImageNode.h>
#import <AsyncDisplayKit/UIImage+ASConvenience.h>
#import "ASSnapshotTestCase.h"
@interface UIImage_ASConvenienceTests : ASSnapshotTestCase
@end
@implementation UIImage_ASConvenienceTests
- (UIImage*) imageWithColor:(UIColor *)color {
UIGraphicsBeginImageContext(CGSizeMake(100, 100));
[color setFill];
UIRectFill(CGRectMake(0, 0, 100, 100));
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
- (void)testRoundedPartial {
ASImageNode *node = [[ASImageNode alloc] init];
UIImage *image = [UIImage as_resizableRoundedImageWithCornerRadius:50.0
cornerColor:UIColor.redColor
fillColor:UIColor.greenColor
borderColor:UIColor.blueColor
borderWidth:4.0
roundedCorners:UIRectCornerTopLeft | UIRectCornerBottomRight
scale:2.0
traitCollection:ASPrimitiveTraitCollectionMakeDefault()];
node.image = image;
ASDisplayNodeSizeToFitSize(node, CGSizeMake(1000, 1000));
ASSnapshotVerifyNode(node, nil);
}
- (void)testRoundedAllCorners {
ASImageNode *node = [[ASImageNode alloc] init];
UIImage *image = [UIImage as_resizableRoundedImageWithCornerRadius:50.0
cornerColor:UIColor.redColor
fillColor:UIColor.greenColor
borderColor:UIColor.blueColor
borderWidth:4.0
traitCollection:ASPrimitiveTraitCollectionMakeDefault()];
node.image = image;
ASDisplayNodeSizeToFitSize(node, CGSizeMake(1000, 1000));
ASSnapshotVerifyNode(node, nil);
}
- (void)testRoundedBorderless {
ASImageNode *node = [[ASImageNode alloc] init];
UIImage *image = [UIImage as_resizableRoundedImageWithCornerRadius:50.0
cornerColor:UIColor.redColor
fillColor:UIColor.greenColor
traitCollection:ASPrimitiveTraitCollectionMakeDefault()];
node.image = image;
ASDisplayNodeSizeToFitSize(node, CGSizeMake(1000, 1000));
ASSnapshotVerifyNode(node, nil);
}
@end