diff --git a/MMMTestCase.podspec b/MMMTestCase.podspec index b79a8fa..3025c4a 100644 --- a/MMMTestCase.podspec +++ b/MMMTestCase.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.name = "MMMTestCase" - s.version = "1.10.0" + s.version = "1.11.0" s.summary = "Our helpers for FBTestCase and XCTestCase" s.description = s.summary s.homepage = "https://github.com/mediamonks/#{s.name}" diff --git a/Sources/MMMTestCaseObjC/MMMTestCase.m b/Sources/MMMTestCaseObjC/MMMTestCase.m index 3f5eb82..740628b 100644 --- a/Sources/MMMTestCaseObjC/MMMTestCase.m +++ b/Sources/MMMTestCaseObjC/MMMTestCase.m @@ -532,9 +532,13 @@ - (void)verifyView:(UIView *)view fitSize:(CGSize)fitSize identifier:(NSString * MMMTestCaseContainer *outerContainer = [[MMMTestCaseContainer alloc] init]; outerContainer.backgroundColor = backgroundColor ?: [UIColor whiteColor]; - // To ensure any small updates scheduled on the current run loop (or dispatch queue attached to it) are procesed before we begin measuring things. + // To ensure any small updates scheduled on the current run loop (or dispatch queue attached to it) are processed before we begin measuring things. [self pumpRunLoopABit]; + // Let's remember the superview this view was a part of, to restore this afterwards. + UIView *originalSuperview = view.superview; + NSInteger originalIndex = originalSuperview ? [view.superview.subviews indexOfObjectIdenticalTo:view] : NSNotFound; + CGSize size; if (view.translatesAutoresizingMaskIntoConstraints) { @@ -546,6 +550,13 @@ - (void)verifyView:(UIView *)view fitSize:(CGSize)fitSize identifier:(NSString * } else { + // Let's have a window to make sure sizing works properly with layouts involving many + // multi-line labels depending on each other. + UIWindow *window = [[UIWindow alloc] init]; + [window setHidden:NO]; + [window setWindowLevel:-1]; + [window addSubview:view]; + [view updateConstraintsIfNeeded]; size = [view @@ -558,10 +569,6 @@ - (void)verifyView:(UIView *)view fitSize:(CGSize)fitSize identifier:(NSString * ]; } - // Let's remember the superview this view was a part of, to restore this afterwards. - UIView *originalSuperview = view.superview; - NSInteger originalIndex = originalSuperview ? [view.superview.subviews indexOfObjectIdenticalTo:view] : NSNotFound; - [outerContainer setChildView:view size:size]; CGSize containerSize = [outerContainer sizeThatFits:CGSizeZero]; outerContainer.frame = CGRectMake(0, 0, containerSize.width, containerSize.height);