Summary: Originally, we thought that skipping the measurement of views that were hidden would be a nice optimiatzion. Upon further review, we saw that according to Apple's `UIView` documentation: > A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual. So, to keep parity with common iOS layout APIs, we are going to size and layout views, even if they are hidden. Reviewed By: emilsjolander Differential Revision: D4051225 fbshipit-source-id: 0794cbad293a7de83d109dad2b3983d83845d145
50 lines
1.2 KiB
Objective-C
50 lines
1.2 KiB
Objective-C
/**
|
|
* 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/XCTest.h>
|
|
|
|
#import "UIView+CSSLayout.h"
|
|
|
|
@interface CSSLayoutTests : XCTestCase
|
|
@end
|
|
|
|
@implementation CSSLayoutTests
|
|
|
|
- (void)testNodesAreDeallocedWithSingleView
|
|
{
|
|
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
|
|
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
[view css_setFlex:1];
|
|
XCTAssertEqual(1, CSSNodeGetInstanceCount());
|
|
view = nil;
|
|
|
|
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
|
}
|
|
|
|
- (void)testNodesAreDeallocedCascade
|
|
{
|
|
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
|
|
|
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
|
|
[view css_setFlex:1];
|
|
|
|
for (int i=0; i<10; i++) {
|
|
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
|
|
[subview css_setFlex:1];
|
|
[view addSubview:subview];
|
|
}
|
|
XCTAssertEqual(11, CSSNodeGetInstanceCount());
|
|
view = nil;
|
|
|
|
XCTAssertEqual(0, CSSNodeGetInstanceCount());
|
|
}
|
|
|
|
@end
|