Test inset MGLMapView
Verify that the ornaments hug the `MGLMapView` when it’s smaller than the view controller’s root view.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
@interface MGLTViewController : UIViewController
|
||||
|
||||
- (void)insetMapView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user