Skip to content

Commit

Permalink
Fix synchronous state of node if +viewClass is overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
maicki committed Jan 30, 2018
1 parent fef965f commit 9dc7a4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ - (void)_initializeInstance
#endif

_viewClass = [self.class viewClass];
setFlag(Synchronous, ![_viewClass isSubclassOfClass:[_ASDisplayView class]]);

_layerClass = [self.class layerClass];

_contentsScaleForDisplay = ASScreenScale();
_drawingPriority = ASDefaultDrawingPriority;

Expand Down
13 changes: 13 additions & 0 deletions Tests/ASDisplayNodeTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ - (void)displayWillStartAsynchronously:(BOOL)asynchronously

@end

@interface ASSynchronousTestDisplayNode : ASDisplayNode
@end

@implementation ASSynchronousTestDisplayNode
+ (Class)viewClass { return [UIView class]; }
@end

@interface UIDisplayNodeTestView : UIView
@end

Expand Down Expand Up @@ -2354,4 +2361,10 @@ - (void)testScreenScale
XCTAssertEqual(ASScreenScale(), UIScreen.mainScreen.scale);
}

- (void)testThatIfViewClassIsOverwrittenItsSynchronous
{
ASSynchronousTestDisplayNode *node = [[ASSynchronousTestDisplayNode alloc] init];
XCTAssertTrue([node isSynchronous], @"Node should be synchronous if viewClass is ovewritten and not a subclass of _ASDisplayView");
}

@end

0 comments on commit 9dc7a4b

Please sign in to comment.