My class has logic for inserting views in certain levels in the hierarchy.
containerView = [[UIView alloc] init];
shadowView = [[UIView alloc] init];
contentView = [[UIView alloc init];
[containerView addSubview:shadowView];
[containerView insertSubview:contentView belowSubview:shadowView];
Later down the line, it flips them so the shadow view is below the content view instead of above it.
// "Flipping" their positions.
[containerView insertSubview:contentView aboveSubview:shadowView];
UIView has a subviews
property returning an NSArray, unfortunately the array does not reflect the view stack ordering.
I want to unit test the placement of the view compared to it's siblings. How can I do that?
Here's an example of a test.
- (void)testViewHierarchyFlipping {
STAssertEquals(containerView, shadowView.superview, nil);
STAssertEquals(containerView, contentView.superview, nil);
// Test that shadowView is ABOVE contentView.
}