forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASTLayoutFixture.h
60 lines (41 loc) · 2.06 KB
/
ASTLayoutFixture.h
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
//
// ASTLayoutFixture.h
// Texture
//
// Copyright (c) Pinterest, Inc. All rights reserved.
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
#import <Foundation/Foundation.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import "ASTestCase.h"
#import "ASLayoutTestNode.h"
NS_ASSUME_NONNULL_BEGIN
AS_SUBCLASSING_RESTRICTED
@interface ASTLayoutFixture : NSObject
/// The correct layout. The root should be unpositioned (same as -calculatedLayout).
@property (nonatomic, nullable) ASLayout *layout;
/// The layoutSpecBlocks for non-leaf nodes.
@property (nonatomic, readonly) NSMapTable<ASDisplayNode *, ASLayoutSpecBlock> *layoutSpecBlocks;
@property (nonatomic, readonly) ASLayoutTestNode *rootNode;
@property (nonatomic, readonly) NSSet<ASLayoutTestNode *> *allNodes;
/// Get the (correct) layout for the specified node.
- (ASLayout *)layoutForNode:(ASLayoutTestNode *)node;
/// Add this to the list of expected size ranges for the given node.
- (void)addSizeRange:(ASSizeRange)sizeRange forNode:(ASLayoutTestNode *)node;
/// If you have a node that wants a size different than it gets, set it here.
/// For any leaf nodes that you don't call this on, the node will return the correct size
/// based on the fixture's layout. This is useful for triggering multipass stack layout.
- (void)setReturnedSize:(CGSize)size forNode:(ASLayoutTestNode *)node;
/// Get the first expected size range for the node.
- (ASSizeRange)firstSizeRangeForNode:(ASLayoutTestNode *)node;
/// Enumerate all the size ranges for all the nodes using the provided block.
- (void)withSizeRangesForAllNodesUsingBlock:(void (^)(ASLayoutTestNode *node, ASSizeRange sizeRange))block;
/// Enumerate all the size ranges for the node.
- (void)withSizeRangesForNode:(ASLayoutTestNode *)node block:(void (^)(ASSizeRange sizeRange))block;
/// Configure the nodes for this fixture. Set testSize on leaf nodes, layoutSpecBlock on container nodes.
- (void)apply;
@end
@interface ASLayout (TestHelpers)
@property (nonatomic, readonly) NSArray<ASDisplayNode *> *allNodes;
@end
NS_ASSUME_NONNULL_END