Skip to content

iOS7 and running the unit tests #128

@seanoshea

Description

@seanoshea

I'm not fully sure that this is definitely an issue, but am opening it as such after being prompted to do so on twitter (https://twitter.com/seanoshea/status/567809726965350400).

https://github.com/seanoshea/RZUtils/tree/unit-tests is a unit-testing branch that I've started to work on a little. The tests pass without any issues on iOS8, but layoutSubviews isn't being invoked on the containerView when the tests are run on iOS7.

Here's the output of the tests when run on iOS7:

Test Suite 'All tests' started at 2015-02-17 23:30:19 +0000
Test Suite 'RZUtilsTests.xctest' started at 2015-02-17 23:30:22 +0000
Test Suite 'RZAutoLayoutHelpersTest' started at 2015-02-17 23:30:22 +0000
Test Case '-[RZAutoLayoutHelpersTest testCenteringViews]' started.
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:109: error: -    [RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameOne.origin.x valueTwo:375.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:110: error: -    [RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameOne.origin.y valueTwo:375.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:111: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameOne.size.width valueTwo:250.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:112: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameOne.size.height valueTwo:250.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:114: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:CGRectGetMidX(frameOne) valueTwo:500.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:115: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:CGRectGetMidY(frameOne) valueTwo:500.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:119: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameTwo.origin.x valueTwo:412.5f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:120: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameTwo.origin.y valueTwo:335.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:121: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameTwo.size.width valueTwo:175.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:122: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:frameTwo.size.height valueTwo:330.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:124: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:CGRectGetMidX(frameTwo) valueTwo:500.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:125: error: -[RZAutoLayoutHelpersTest testCenteringViews] : (([self roundedEquals:CGRectGetMidY(frameTwo) valueTwo:500.0f]) is true) failed
Test Case '-[RZAutoLayoutHelpersTest testCenteringViews]' failed (0.005 seconds).
Test Case '-[RZAutoLayoutHelpersTest testCenteringWithOffsetViews]' started.
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:144: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameOne.origin.x valueTwo:397.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:145: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameOne.origin.y valueTwo:397.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:146: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameOne.size.width valueTwo:250.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:147: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameOne.size.height valueTwo:250.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:149: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:CGRectGetMidX(frameOne) valueTwo:522.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:150: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:CGRectGetMidY(frameOne) valueTwo:522.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:154: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameTwo.origin.x valueTwo:434.5f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:155: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameTwo.origin.y valueTwo:357.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:156: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameTwo.size.width valueTwo:175.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:157: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:frameTwo.size.height valueTwo:330.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:159: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:CGRectGetMidX(frameTwo) valueTwo:522.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:160: error: -[RZAutoLayoutHelpersTest testCenteringWithOffsetViews] : (([self roundedEquals:CGRectGetMidY(frameTwo) valueTwo:522.0f]) is true) failed
Test Case '-[RZAutoLayoutHelpersTest testCenteringWithOffsetViews]' failed (0.003 seconds).
Test Case '-[RZAutoLayoutHelpersTest testPinningViews]' started.
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:190: error: -[RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameOne.size.width valueTwo:RZAutoLayoutHelpersTestContainerWidth]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:191: error: -[RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameOne.size.height valueTwo:RZAutoLayoutHelpersTestContainerHeight]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:195: error: -[RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameTwo.origin.x valueTwo:17.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:196: error: -[RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameTwo.origin.y valueTwo:21.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:197: error: -[RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameTwo.size.width valueTwo:962.0f]) is true) failed
/Users/Sean/dev/github/RZUtils/Tests/RZUtilsTests/RZAutoLayoutHelpersTest.m:198: error: -    [RZAutoLayoutHelpersTest testPinningViews] : (([self roundedEquals:frameTwo.size.height valueTwo:962.0f]) is true) failed
Test Case '-[RZAutoLayoutHelpersTest testPinningViews]' failed (0.001 seconds).
Test Suite 'RZAutoLayoutHelpersTest' failed at 2015-02-17 23:30:22 +0000.
 Executed 3 tests, with 30 failures (0 unexpected) in 0.008 (0.008) seconds
Test Suite 'RZAutoLayoutTests' started at 2015-02-17 23:30:22 +0000
Test Case '-[RZAutoLayoutTests testMultipleLevels]' started.
Test Case '-[RZAutoLayoutTests testMultipleLevels]' passed (0.000 seconds).
Test Case '-[RZAutoLayoutTests testParentChildAndUnrelated]' started.
Test Case '-[RZAutoLayoutTests testParentChildAndUnrelated]' passed (0.000 seconds).
Test Case '-[RZAutoLayoutTests testParentChildOrder1]' started.
Test Case '-[RZAutoLayoutTests testParentChildOrder1]' passed (0.000 seconds).
Test Case '-[RZAutoLayoutTests testReturnsSingleView]' started.
Test Case '-[RZAutoLayoutTests testReturnsSingleView]' passed (0.000 seconds).
Test Case '-[RZAutoLayoutTests testTwoUnrelatedViews]' started.
Test Case '-[RZAutoLayoutTests testTwoUnrelatedViews]' passed (0.000 seconds).
Test Suite 'RZAutoLayoutTests' passed at 2015-02-17 23:30:22 +0000.
 Executed 5 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
Test Suite 'RZBlockKVOTests' started at 2015-02-17 23:30:22 +0000
Test Case '-[RZBlockKVOTests testObservation]' started.
Test Case '-[RZBlockKVOTests testObservation]' passed (0.001 seconds).
Test Case '-[RZBlockKVOTests testObserverDeallocation]' started.
Test Case '-[RZBlockKVOTests testObserverDeallocation]' passed (0.000 seconds).
Test Case '-[RZBlockKVOTests testObserverRemoval]' started.
Test Case '-[RZBlockKVOTests testObserverRemoval]' passed (0.000 seconds).
Test Suite 'RZBlockKVOTests' passed at 2015-02-17 23:30:22 +0000.
 Executed 3 tests, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'RZUtilsTests.xctest' failed at 2015-02-17 23:30:22 +0000.
 Executed 11 tests, with 30 failures (0 unexpected) in 0.010 (0.012) seconds
Test Suite 'All tests' failed at 2015-02-17 23:30:22 +0000.
 Executed 11 tests, with 30 failures (0 unexpected) in 0.010 (2.711) seconds
Program ended with exit code: 1

I'm trying to force layoutSubviews with the following code:

- (void)forceConstraintsEvaluationForAllSubviewsOfView:(UIView *)view
{
    for (UIView *subview in view.subviews) {
        [self forceConstraintsEvaluationForAllSubviewsOfView:subview];
    }
    [view setNeedsLayout];
    [view layoutIfNeeded];
}

but it doesn't seem to be doing the trick on iOS7.

Is it required to be able to run the unit tests on iOS7 (the pod spec would seem to indicate so)? If so, might someone have a suggestion for how to force layoutSubviews to get called when the constrains are added to the testViewOne and testViewTwo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions