forked from PureLayout/PureLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPureLayoutTestBase.h
More file actions
75 lines (56 loc) · 3.93 KB
/
Copy pathPureLayoutTestBase.h
File metadata and controls
75 lines (56 loc) · 3.93 KB
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
//
// PureLayoutTestBase.h
// PureLayout Tests
//
// Copyright (c) 2014 Tyler Fox
// https://github.com/smileyborg/PureLayout
//
#import <XCTest/XCTest.h>
#import "PureLayout.h"
#import "PureLayout+Internal.h"
#if TARGET_OS_IPHONE
#define VALUES(iOS, OSX) (iOS) // a macro that takes a value for each platform, and substitutes the value for the current platform
#define ALLabel UILabel
#define ALImageView UIImageView
#else
#define VALUES(iOS, OSX) (OSX) // a macro that takes a value for each platform, and substitutes the value for the current platform
#define ALLabel NSTextView
#define ALImageView NSImageView
#endif /* TARGET_OS_IPHONE */
#define EPSILON 1.0 // the allowable delta between the expected result and the actual result (due to rounding)
#define ROUNDED_EQUALS(a, b) (fabs((a) - (b)) < EPSILON)
#define ALAssertFrameEquals(view, x, y, w, h) XCTAssert(ROUNDED_EQUALS(CGRectGetMinX(view.frame), x) && ROUNDED_EQUALS(CGRectGetMinY(view.frame), y) && ROUNDED_EQUALS(CGRectGetWidth(view.frame), w) && ROUNDED_EQUALS(CGRectGetHeight(view.frame), h))
#define ALAssertOriginEquals(view, x, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMinX(view.frame), x) && ROUNDED_EQUALS(CGRectGetMinY(view.frame), y))
#define ALAssertCenterEquals(view, x, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMidX(view.frame), x) && ROUNDED_EQUALS(CGRectGetMidY(view.frame), y))
#define ALAssertMaxEquals(view, x, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMaxX(view.frame), x) && ROUNDED_EQUALS(CGRectGetMaxY(view.frame), y))
#define ALAssertSizeEquals(view, w, h) XCTAssert(ROUNDED_EQUALS(CGRectGetWidth(view.frame), w) && ROUNDED_EQUALS(CGRectGetHeight(view.frame), h))
#define ALAssertOriginXEquals(view, x) XCTAssert(ROUNDED_EQUALS(CGRectGetMinX(view.frame), x))
#define ALAssertOriginYEquals(view, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMinY(view.frame), y))
#define ALAssertCenterXEquals(view, x) XCTAssert(ROUNDED_EQUALS(CGRectGetMidX(view.frame), x))
#define ALAssertCenterYEquals(view, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMidY(view.frame), y))
#define ALAssertMaxXEquals(view, x) XCTAssert(ROUNDED_EQUALS(CGRectGetMaxX(view.frame), x))
#define ALAssertMaxYEquals(view, y) XCTAssert(ROUNDED_EQUALS(CGRectGetMaxY(view.frame), y))
#define ALAssertWidthEquals(view, w) XCTAssert(ROUNDED_EQUALS(CGRectGetWidth(view.frame), w))
#define ALAssertHeightEquals(view, h) XCTAssert(ROUNDED_EQUALS(CGRectGetHeight(view.frame), h))
static const CGFloat kContainerViewWidth = 1000.0;
static const CGFloat kContainerViewHeight = 1000.0;
@interface PureLayoutTestBase : XCTestCase
// An array of viewA, viewB, viewC, and viewD
@property (nonatomic, readonly) NSArray *viewArray;
// The indendentation below represents how the view hierarchy is set up
@property (nonatomic, strong) ALView *containerView;
@property (nonatomic, strong) ALView * viewA;
@property (nonatomic, strong) ALView * viewA_A;
@property (nonatomic, strong) ALView * viewA_A_A;
@property (nonatomic, strong) ALView * viewA_A_B;
@property (nonatomic, strong) ALView * viewA_B;
@property (nonatomic, strong) ALView * viewA_B_A;
@property (nonatomic, strong) ALView * viewB;
@property (nonatomic, strong) ALView * viewB_A;
@property (nonatomic, strong) ALView * viewC;
@property (nonatomic, strong) ALView * viewD;
/** Forces the container view to immediately do a layout pass, which will evaluate the constraints and set the frames for the container view and subviews. */
- (void)evaluateConstraints;
/** Forces the given view to immediately do a layout pass, which will evaluate the constraints and set the frames for the view and any subviews. */
- (void)evaluateConstraintsForView:(ALView *)view;
@end