mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-23 19:31:21 +08:00
Add ASDisplayNodeLayoutTests (#2157)
This commit is contained in:
committed by
Adlai Holler
parent
ff37535140
commit
d0c77d7965
37
AsyncDisplayKitTests/ASDisplayNodeLayoutTests.mm
Normal file
37
AsyncDisplayKitTests/ASDisplayNodeLayoutTests.mm
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// ASDisplayNodeLayoutTests.m
|
||||
// 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 "ASXCTExtensions.h"
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
#import "ASLayoutSpecSnapshotTestsHelper.h"
|
||||
#import "ASDisplayNode+FrameworkPrivate.h"
|
||||
|
||||
|
||||
@interface ASDisplayNodeLayoutTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation ASDisplayNodeLayoutTests
|
||||
|
||||
- (void)testMeasurePassOnLayoutIfNotHappenedBefore
|
||||
{
|
||||
ASStaticSizeDisplayNode *displayNode = [ASStaticSizeDisplayNode new];
|
||||
displayNode.staticSize = CGSizeMake(100, 100);
|
||||
displayNode.frame = CGRectMake(0, 0, 100, 100);
|
||||
|
||||
ASXCTAssertEqualSizes(displayNode.calculatedSize, CGSizeZero, @"Calculated size before measurement and layout should be 0");
|
||||
|
||||
// Trigger view creation and layout pass without a manual measure: call before so the automatic measurement
|
||||
// pass will trigger in the layout pass
|
||||
[displayNode.view layoutIfNeeded];
|
||||
|
||||
ASXCTAssertEqualSizes(displayNode.calculatedSize, CGSizeMake(100, 100), @"Automatic measurement pass should be happened in layout");
|
||||
}
|
||||
|
||||
@end
|
||||
37
AsyncDisplayKitTests/ASXCTExtensions.h
Normal file
37
AsyncDisplayKitTests/ASXCTExtensions.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// ASDisplayNodeLayoutTests.m
|
||||
// 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 <XCTest/XCTestAssertionsImpl.h>
|
||||
|
||||
/**
|
||||
* XCTest extensions for CGGeometry.
|
||||
*
|
||||
* Prefer these to XCTAssert(CGRectEqualToRect(...)) because you get output
|
||||
* that tells you what went wrong.
|
||||
* Could use NSValue, but using strings makes the description messages shorter.
|
||||
*/
|
||||
|
||||
#define ASXCTAssertEqualSizes(s0, s1, ...) \
|
||||
_XCTPrimitiveAssertEqualObjects(self, NSStringFromCGSize(s0), @#s0, NSStringFromCGSize(s1), @#s1, __VA_ARGS__)
|
||||
|
||||
#define ASXCTAssertNotEqualSizes(s0, s1, ...) \
|
||||
_XCTPrimitiveAssertNotEqualObjects(self, NSStringFromCGSize(s0), @#s0, NSStringFromCGSize(s1), @#s1, __VA_ARGS__)
|
||||
|
||||
#define ASXCTAssertEqualPoints(p0, p1, ...) \
|
||||
_XCTPrimitiveAssertEqualObjects(self, NSStringFromCGPoint(p0), @#p0, NSStringFromCGPoint(p1), @#p1, __VA_ARGS__)
|
||||
|
||||
#define ASXCTAssertNotEqualPoints(p0, p1, ...) \
|
||||
_XCTPrimitiveAssertNotEqualObjects(self, NSStringFromCGPoint(p0), @#p0, NSStringFromCGPoint(p1), @#p1, __VA_ARGS__)
|
||||
|
||||
#define ASXCTAssertEqualRects(r0, r1, ...) \
|
||||
_XCTPrimitiveAssertEqualObjects(self, NSStringFromCGRect(r0), @#r0, NSStringFromCGRect(r1), @#r1, __VA_ARGS__)
|
||||
|
||||
#define ASXCTAssertNotEqualRects(r0, r1, ...) \
|
||||
_XCTPrimitiveAssertNotEqualObjects(self, NSStringFromCGRect(r0), @#r0, NSStringFromCGRect(r1), @#r1, __VA_ARGS__)
|
||||
Reference in New Issue
Block a user