summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-04-24 13:30:50 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-04-24 13:30:50 -0700
commit1dc2cbc280292c76eaca21fde9dddfbd30060fb0 (patch)
tree836025881b28fd592bbcef72670345a720e9af0b /test
parent2c436444d7ebf22ca48ef08e077a144ddea76ffd (diff)
downloadqtlocation-mapboxgl-1dc2cbc280292c76eaca21fde9dddfbd30060fb0.tar.gz
Test inset MGLMapView
Verify that the ornaments hug the `MGLMapView` when it’s smaller than the view controller’s root view.
Diffstat (limited to 'test')
-rw-r--r--test/ios/KIFTestActor+MapboxGL.h4
-rw-r--r--test/ios/KIFTestActor+MapboxGL.m4
-rw-r--r--test/ios/MGLTViewController.h2
-rw-r--r--test/ios/MGLTViewController.m16
-rw-r--r--test/ios/MapViewTests.m23
5 files changed, 41 insertions, 8 deletions
diff --git a/test/ios/KIFTestActor+MapboxGL.h b/test/ios/KIFTestActor+MapboxGL.h
index df83b2377a..d16e348486 100644
--- a/test/ios/KIFTestActor+MapboxGL.h
+++ b/test/ios/KIFTestActor+MapboxGL.h
@@ -1,12 +1,12 @@
#import <UIKit/UIKit.h>
#import <KIF/KIF.h>
-@class MGLMapView;
+@class MGLTViewController, MGLMapView;
@interface KIFTestActor (MapboxGL)
@property (nonatomic, readonly) UIWindow *window;
-@property (nonatomic, readonly) UIViewController *viewController;
+@property (nonatomic, readonly) MGLTViewController *viewController;
@property (nonatomic, readonly) MGLMapView *mapView;
@property (nonatomic, readonly) UIView *compass;
diff --git a/test/ios/KIFTestActor+MapboxGL.m b/test/ios/KIFTestActor+MapboxGL.m
index ef40c1bed1..330adfdc28 100644
--- a/test/ios/KIFTestActor+MapboxGL.m
+++ b/test/ios/KIFTestActor+MapboxGL.m
@@ -10,8 +10,8 @@
return [[UIApplication sharedApplication] statusBarWindow];
}
-- (UIViewController *)viewController {
- return (UIViewController *)[[tester.mapView nextResponder] nextResponder];
+- (MGLTViewController *)viewController {
+ return (MGLTViewController *)[[tester.mapView nextResponder] nextResponder];
}
- (MGLMapView *)mapView {
diff --git a/test/ios/MGLTViewController.h b/test/ios/MGLTViewController.h
index 39df59bb5e..f8d5618993 100644
--- a/test/ios/MGLTViewController.h
+++ b/test/ios/MGLTViewController.h
@@ -2,4 +2,6 @@
@interface MGLTViewController : UIViewController
+- (void)insetMapView;
+
@end
diff --git a/test/ios/MGLTViewController.m b/test/ios/MGLTViewController.m
index e839c45047..2cb2b939c7 100644
--- a/test/ios/MGLTViewController.m
+++ b/test/ios/MGLTViewController.m
@@ -2,17 +2,25 @@
#import "MapboxGL.h"
@implementation MGLTViewController
+{
+ MGLMapView *_mapView;
+}
- (void)viewDidLoad
{
[super viewDidLoad];
- MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
+ _mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
accessToken:@"pk.eyJ1IjoianVzdGluIiwiYSI6Ik9RX3RRQzAifQ.dmOg_BAp1ywuDZMM7YsXRg"];
- mapView.viewControllerForLayoutGuides = self;
- mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ _mapView.viewControllerForLayoutGuides = self;
+ _mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [self.view addSubview:mapView];
+ [self.view addSubview:_mapView];
+}
+
+- (void)insetMapView
+{
+ _mapView.frame = CGRectInset(_mapView.frame, 50, 50);
}
@end
diff --git a/test/ios/MapViewTests.m b/test/ios/MapViewTests.m
index deed521b71..2d87b43c15 100644
--- a/test/ios/MapViewTests.m
+++ b/test/ios/MapViewTests.m
@@ -4,6 +4,7 @@
#import "KIFTestActor+MapboxGL.h"
#import "MapboxGL.h"
+#import "MGLTViewController.h"
@interface MapViewTests : KIFTestCase <MGLMapViewDelegate>
@@ -297,6 +298,28 @@
@"rotated device should not have attribution button under toolbar");
}
+- (void)testInsetMapView {
+ [tester.viewController insetMapView];
+ [tester waitForAnimationsToFinish];
+
+ UIView *logoBug = (UIView *)[tester waitForViewWithAccessibilityLabel:@"Mapbox logo"];
+ UIView *attributionButton = (UIView *)[tester waitForViewWithAccessibilityLabel:@"Attribution info"];
+
+ CGRect mapViewFrame = [tester.mapView.superview convertRect:tester.mapView.frame toView:nil];
+
+ CGRect logoBugFrame = [logoBug.superview convertRect:logoBug.frame toView:nil];
+ XCTAssertTrue(CGRectIntersectsRect(logoBugFrame, mapViewFrame),
+ @"logo bug should lie inside shrunken map view");
+
+ CGRect attributionButtonFrame = [attributionButton.superview convertRect:attributionButton.frame toView:nil];
+ XCTAssertTrue(CGRectIntersectsRect(attributionButtonFrame, mapViewFrame),
+ @"attribution button should lie inside shrunken map view");
+
+ CGRect compassFrame = [tester.compass.superview convertRect:tester.compass.frame toView:nil];
+ XCTAssertTrue(CGRectIntersectsRect(compassFrame, mapViewFrame),
+ @"compass should lie inside shrunken map view");
+}
+
- (void)testDelegateRegionWillChange {
__block NSUInteger unanimatedCount;
__block NSUInteger animatedCount;