From cab756374f4eb42ab632c6db6d049a90884700ad Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 4 Oct 2019 11:15:20 -0400 Subject: [ios] Fix layout of Scale bar components (#15703) * [ios] Add failing tests for scale bar updates. * [ios] Remove borderLayer * [ios] Ensure bar sections have non-fractional width * [ios] Add RTL override * [ios] Update constraints/layout * [ios] Invalidate scalebars size, after the parent's layout has happened (to ensure the view dimensions are correct when re-laying out the scale bar. * [ios] Refactor layout * [ios] Update changelog / remove commented code. * [ios] Remove whitespace * [ios] Stop integration tests asserting (when scale bar is hidden). Also reduces the # of calculations (since updateConstraints and layoutSubviews can be called outside of our control). * [ios] Moves declaration of properties for testing. * [ios] Removes redundant property attribute * [ios] Updated change log --- platform/ios/test/MGLMapViewScaleBarTests.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'platform/ios/test/MGLMapViewScaleBarTests.m') diff --git a/platform/ios/test/MGLMapViewScaleBarTests.m b/platform/ios/test/MGLMapViewScaleBarTests.m index 29acc75d7f..b4f81ef62b 100644 --- a/platform/ios/test/MGLMapViewScaleBarTests.m +++ b/platform/ios/test/MGLMapViewScaleBarTests.m @@ -36,11 +36,14 @@ XCTAssertFalse(scaleBar.hidden); // Scale bar should not be visible at default zoom (~z0), but it should be ready. - XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + // Size is not a measure of readiness here though. + XCTAssertTrue(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); XCTAssertEqual(scaleBar.alpha, 0); self.mapView.zoomLevel = 15; + [self.mapView layoutIfNeeded]; XCTAssertGreaterThan(scaleBar.alpha, 0); + XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); } - (void)testDirectlySettingScaleBarViewHiddenProperty { @@ -54,10 +57,14 @@ // ... but triggering any camera event will update it. self.mapView.zoomLevel = 1; - XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); + [self.mapView layoutIfNeeded]; + + XCTAssertTrue(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); XCTAssertEqual(scaleBar.alpha, 0); self.mapView.zoomLevel = 15; + [self.mapView layoutIfNeeded]; + XCTAssertGreaterThan(scaleBar.alpha, 0); -} -@end + XCTAssertFalse(CGSizeEqualToSize(scaleBar.intrinsicContentSize, CGSizeZero)); +}@end -- cgit v1.2.1