summaryrefslogtreecommitdiff
path: root/platform/ios/test/MGLMapViewLayoutTests.m
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/test/MGLMapViewLayoutTests.m')
-rw-r--r--platform/ios/test/MGLMapViewLayoutTests.m70
1 files changed, 67 insertions, 3 deletions
diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m
index f3eeb75c0d..8d443e0260 100644
--- a/platform/ios/test/MGLMapViewLayoutTests.m
+++ b/platform/ios/test/MGLMapViewLayoutTests.m
@@ -171,6 +171,27 @@
}
}
+- (void)testCompassPlacementInvalidPosition {
+ CGFloat margin = -_superView.bounds.size.width;
+
+ UIView *scaleBar = self.mapView.scaleBar;
+ NSArray *testDataList = [self makeTestDataListWithView:scaleBar margin:margin];
+
+ for (MGLOrnamentTestData *testData in testDataList) {
+ self.mapView.compassViewPosition = testData.position;
+ self.mapView.compassViewMargins = testData.offset;
+
+ //invoke layout
+ [self.superView setNeedsLayout];
+ XCTAssertThrowsSpecificNamed(
+ [self.superView layoutIfNeeded],
+ NSException,
+ NSInvalidArgumentException,
+ @"should throw NSInvalidArgumentException"
+ );
+ }
+}
+
- (void)testScalebarPlacement {
double accuracy = 0.01;
CGFloat margin = 4.0;
@@ -191,6 +212,27 @@
}
}
+- (void)testScalebarPlacementInvalidPosition {
+ CGFloat margin = -_superView.bounds.size.width;
+
+ UIView *scaleBar = self.mapView.scaleBar;
+ NSArray *testDataList = [self makeTestDataListWithView:scaleBar margin:margin];
+
+ for (MGLOrnamentTestData *testData in testDataList) {
+ self.mapView.scaleBarPosition = testData.position;
+ self.mapView.scaleBarMargins = testData.offset;
+
+ //invoke layout
+ [self.superView setNeedsLayout];
+ XCTAssertThrowsSpecificNamed(
+ [self.superView layoutIfNeeded],
+ NSException,
+ NSInvalidArgumentException,
+ @"should throw NSInvalidArgumentException"
+ );
+ }
+}
+
- (void)testAttributionButtonPlacement {
double accuracy = 0.01;
CGFloat margin = 4.0;
@@ -212,15 +254,15 @@
}
- (void)testAttributionButtonPlacementInvalidPosition {
- CGFloat margin = -400.0;
-
+ CGFloat margin = -_superView.bounds.size.width;
+
UIView *attributionButton = self.mapView.attributionButton;
NSArray *testDataList = [self makeTestDataListWithView:attributionButton margin:margin];
for (MGLOrnamentTestData *testData in testDataList) {
self.mapView.attributionButtonPosition = testData.position;
self.mapView.attributionButtonMargins = testData.offset;
-
+
//invoke layout
[self.superView setNeedsLayout];
XCTAssertThrowsSpecificNamed(
@@ -252,4 +294,26 @@
}
}
+- (void)testLogoPlacementInvalidPosition {
+ CGFloat margin = -_superView.bounds.size.width;
+
+ UIView *attributionButton = self.mapView.attributionButton;
+ NSArray *testDataList = [self makeTestDataListWithView:attributionButton margin:margin];
+
+ for (MGLOrnamentTestData *testData in testDataList) {
+ self.mapView.logoViewPosition = testData.position;
+ self.mapView.logoViewMargins = testData.offset;
+
+ //invoke layout
+ [self.superView setNeedsLayout];
+ XCTAssertThrowsSpecificNamed(
+ [self.superView layoutIfNeeded],
+ NSException,
+ NSInvalidArgumentException,
+ @"should throw NSInvalidArgumentException"
+ );
+ }
+}
+
+
@end