|
| 1 | +/* Copyright (c) 2014-present, Facebook, Inc. |
| 2 | + * All rights reserved. |
| 3 | + * |
| 4 | + * This source code is licensed under the BSD-style license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 6 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 7 | + */ |
| 8 | + |
| 9 | +#import "ASSnapshotTestCase.h" |
| 10 | + |
| 11 | +#import <AsyncDisplayKit/ASDisplayNodeInternal.h> |
| 12 | + |
| 13 | +@implementation ASSnapshotTestCase |
| 14 | + |
| 15 | ++ (void)_layoutAndDisplayNode:(ASDisplayNode *)node |
| 16 | +{ |
| 17 | + if (![node __shouldLoadViewOrLayer]) { |
| 18 | + return; |
| 19 | + } |
| 20 | + |
| 21 | + CALayer *layer = node.layer; |
| 22 | + |
| 23 | + [layer setNeedsLayout]; |
| 24 | + [layer layoutIfNeeded]; |
| 25 | + |
| 26 | + [layer setNeedsDisplay]; |
| 27 | + [layer displayIfNeeded]; |
| 28 | +} |
| 29 | + |
| 30 | ++ (void)_recursivelyLayoutAndDisplayNode:(ASDisplayNode *)node |
| 31 | +{ |
| 32 | + for (ASDisplayNode *subnode in node.subnodes) { |
| 33 | + [self _recursivelyLayoutAndDisplayNode:subnode]; |
| 34 | + } |
| 35 | + |
| 36 | + [self _layoutAndDisplayNode:node]; |
| 37 | +} |
| 38 | + |
| 39 | ++ (void)_recursivelySetDisplaysAsynchronously:(BOOL)flag forNode:(ASDisplayNode *)node |
| 40 | +{ |
| 41 | + node.displaysAsynchronously = flag; |
| 42 | + |
| 43 | + for (ASDisplayNode *subnode in node.subnodes) { |
| 44 | + subnode.displaysAsynchronously = flag; |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | ++ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node |
| 49 | +{ |
| 50 | + [self _recursivelySetDisplaysAsynchronously:NO forNode:node]; |
| 51 | + [self _recursivelyLayoutAndDisplayNode:node]; |
| 52 | +} |
| 53 | + |
| 54 | +@end |
0 commit comments