Swiftgram/AsyncDisplayKitTests/ASSnapshotTestCase.h
Adlai Holler 0d439a43b6 [ASTextNode] Add Fast-Paths For Text Measurement and Drawing (#2392)
* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Use maximumNumberOfLines property in text kit fast path

Add reference images

Disable fast-path for max-one-line case

* Remove unneeded snapshot files
2016-10-24 17:05:59 -07:00

43 lines
1.7 KiB
Objective-C

//
// ASSnapshotTestCase.h
// AsyncDisplayKit
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <FBSnapshotTestCase/FBSnapshotTestCase.h>
@class ASDisplayNode;
NSOrderedSet *ASSnapshotTestCaseDefaultSuffixes(void);
#define ASSnapshotVerifyNode(node__, identifier__) \
{ \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayerWithOptions(node__.layer, identifier__, ASSnapshotTestCaseDefaultSuffixes(), 0) \
[node__ setShouldRasterizeDescendants:YES]; \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayerWithOptions(node__.layer, identifier__, ASSnapshotTestCaseDefaultSuffixes(), 0) \
[node__ setShouldRasterizeDescendants:NO]; \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayerWithOptions(node__.layer, identifier__, ASSnapshotTestCaseDefaultSuffixes(), 0) \
}
#define ASSnapshotVerifyLayer(layer__, identifier__) \
FBSnapshotVerifyLayerWithOptions(layer__, identifier__, ASSnapshotTestCaseDefaultSuffixes(), 0);
#define ASSnapshotVerifyView(view__, identifier__) \
FBSnapshotVerifyViewWithOptions(view__, identifier__, ASSnapshotTestCaseDefaultSuffixes(), 0);
@interface ASSnapshotTestCase : FBSnapshotTestCase
/**
* Hack for testing. ASDisplayNode lacks an explicit -render method, so we manually hit its layout & display codepaths.
*/
+ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node;
@end