summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-03-24 15:29:52 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-04-16 11:38:41 -0400
commitefdbcd95f1fcf0b81a243d3930677b35c732286b (patch)
treec9741a50d0dc185bddffb5841b71511f990e56e5
parent278d856372cf2a9d6ad6659d11c0d8491d227d78 (diff)
downloadqtlocation-mapboxgl-efdbcd95f1fcf0b81a243d3930677b35c732286b.tar.gz
[ios] Initial breaking test.
-rw-r--r--platform/ios/Integration Tests/MGLBackgroundIntegrationTest.m134
-rw-r--r--platform/ios/Integration Tests/MGLMockApplication.h22
-rw-r--r--platform/ios/Integration Tests/MGLMockApplication.m28
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj18
-rw-r--r--platform/ios/src/MGLApplication.h16
-rw-r--r--platform/ios/src/MGLMapView.mm71
6 files changed, 270 insertions, 19 deletions
diff --git a/platform/ios/Integration Tests/MGLBackgroundIntegrationTest.m b/platform/ios/Integration Tests/MGLBackgroundIntegrationTest.m
new file mode 100644
index 0000000000..148f019845
--- /dev/null
+++ b/platform/ios/Integration Tests/MGLBackgroundIntegrationTest.m
@@ -0,0 +1,134 @@
+#import "MGLMapViewIntegrationTest.h"
+#import "MGLMockApplication.h"
+
+@interface MGLMapView (BackgroundTests)
+@property (nonatomic) id<MGLApplication> application;
+@property (nonatomic) BOOL rendererWasFlushed;
+@property (nonatomic, getter=isDormant) BOOL dormant;
+@property (nonatomic) CADisplayLink *displayLink;
+@end
+
+@protocol MGLApplication;
+
+typedef void (^MGLNotificationBlock)(NSNotification*);
+
+@interface MGLBackgroundIntegrationTest : MGLMapViewIntegrationTest
+@property (nonatomic) id<MGLApplication> oldApplication;
+@property (nonatomic) MGLMockApplication *mockApplication;
+@property (nonatomic, copy) MGLNotificationBlock willEnterForeground;
+@property (nonatomic, copy) MGLNotificationBlock didEnterBackground;
+@end
+
+@implementation MGLBackgroundIntegrationTest
+
+- (void)setUp {
+
+ self.mockApplication = [[MGLMockApplication alloc] init];
+
+ // Register notifications
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:self.mockApplication];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:self.mockApplication];
+
+ [super setUp];
+
+ // Setup MGLMapView to use our new mocked application
+ // Change notification handling here.
+ self.oldApplication = self.mapView.application;
+ self.mapView.application = self.mockApplication;
+}
+
+- (void)tearDown {
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ // Swap back
+ self.mapView.application = self.oldApplication;
+ self.oldApplication = nil;
+ self.mockApplication = nil;
+
+ [super tearDown];
+}
+
+#pragma mark - Notifications
+
+- (void)willEnterForeground:(NSNotification*)notification {
+ NSLog(@"Test willEnterForeground");
+ if (self.willEnterForeground) {
+ self.willEnterForeground(notification);
+ }
+}
+
+- (void)didEnterBackground:(NSNotification*)notification {
+ NSLog(@"Test didEnterBackground");
+ if (self.didEnterBackground) {
+ self.didEnterBackground(notification);
+ }
+}
+
+#pragma mark - Tests
+
+- (void)testRendererWhenGoingIntoBackground {
+
+ XCTAssertFalse(self.mapView.isDormant);
+ XCTAssertFalse(self.mapView.displayLink.isPaused);
+ XCTAssert(self.mapView.application.applicationState == UIApplicationStateActive);
+ XCTAssertFalse(self.mapView.rendererWasFlushed);
+
+ __weak MGLMapView *weakMapView = self.mapView;
+
+ //
+ // Enter background
+ //
+
+ XCTestExpectation *didEnterBackgroundExpectation = [self expectationWithDescription:@"didEnterBackground"];
+ didEnterBackgroundExpectation.expectedFulfillmentCount = 1;
+ didEnterBackgroundExpectation.assertForOverFulfill = YES;
+
+ self.didEnterBackground = ^(__unused NSNotification *notification){
+ MGLMapView *strongMapView = weakMapView;
+
+ // Remove the map view, and re-add to try and force a bad situation
+ UIView *parentView = strongMapView.superview;
+
+ NSLog(@"Removing MGLMapView from super view");
+ [strongMapView removeFromSuperview];
+
+ // Re-add
+ NSLog(@"Re-adding MGLMapView as child");
+ [parentView addSubview:strongMapView];
+ [strongMapView.topAnchor constraintEqualToAnchor:parentView.topAnchor].active = YES;
+ [strongMapView.leftAnchor constraintEqualToAnchor:parentView.leftAnchor].active = YES;
+ [strongMapView.rightAnchor constraintEqualToAnchor:parentView.rightAnchor].active = YES;
+ [strongMapView.bottomAnchor constraintEqualToAnchor:parentView.bottomAnchor].active = YES;
+ };
+
+ [self.mockApplication enterBackground];
+ [self waitForExpectations:@[didEnterBackgroundExpectation] timeout:2.0];
+
+ XCTAssert(self.mapView.isDormant);
+ XCTAssert(self.mapView.displayLink.isPaused);
+ XCTAssert(self.mapView.application.applicationState == UIApplicationStateBackground);
+ XCTAssert(self.mapView.rendererWasFlushed);
+
+ //
+ // Enter foreground
+ //
+
+ XCTestExpectation *willEnterForegroundExpectation = [self expectationWithDescription:@"willEnterForeground"];
+ willEnterForegroundExpectation.expectedFulfillmentCount = 1;
+ willEnterForegroundExpectation.assertForOverFulfill = YES;
+
+ self.willEnterForeground = ^(NSNotification *notification) {
+ [willEnterForegroundExpectation fulfill];
+ };
+
+ [self.mockApplication enterForeground];
+ [self waitForExpectations:@[willEnterForegroundExpectation] timeout:2.0];
+
+ XCTAssertFalse(self.mapView.isDormant);
+ XCTAssertFalse(self.mapView.displayLink.isPaused);
+ XCTAssert(self.mapView.application.applicationState == UIApplicationStateActive);
+ XCTAssert(self.mapView.rendererWasFlushed);
+}
+
+@end
diff --git a/platform/ios/Integration Tests/MGLMockApplication.h b/platform/ios/Integration Tests/MGLMockApplication.h
new file mode 100644
index 0000000000..7f5fef323c
--- /dev/null
+++ b/platform/ios/Integration Tests/MGLMockApplication.h
@@ -0,0 +1,22 @@
+#import <Foundation/Foundation.h>
+#import "../src/MGLApplication.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MGLMockApplication : NSObject <MGLApplication>
+
+- (void)enterBackground;
+- (void)enterForeground;
+
+#pragma mark - MGLApplication
+
+@property(nonatomic, readonly) UIApplicationState applicationState;
+@property(nonatomic, nullable, assign) id<UIApplicationDelegate> delegate;
+@property(nonatomic, readonly) UIInterfaceOrientation statusBarOrientation __TVOS_PROHIBITED;
+
+// TODO: support openURL:options:completionHandler:
+- (BOOL)openURL:(NSURL*)url NS_DEPRECATED_IOS(2_0, 10_0, "Please use openURL:options:completionHandler: instead") NS_EXTENSION_UNAVAILABLE_IOS("");
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/ios/Integration Tests/MGLMockApplication.m b/platform/ios/Integration Tests/MGLMockApplication.m
new file mode 100644
index 0000000000..e472b52d42
--- /dev/null
+++ b/platform/ios/Integration Tests/MGLMockApplication.m
@@ -0,0 +1,28 @@
+#import "MGLMockApplication.h"
+
+#define TRACE() NSLog(@"%s", __PRETTY_FUNCTION__)
+
+@implementation MGLMockApplication
+
+- (instancetype)init {
+ if ((self = [super init])) {
+ _applicationState = UIApplicationStateActive;
+ _statusBarOrientation = UIInterfaceOrientationUnknown;
+ }
+ return self;
+}
+
+- (void)enterBackground {
+ TRACE();
+}
+
+- (void)enterForeground {
+ TRACE();
+}
+
+- (BOOL)openURL:(NSURL*)url {
+ TRACE();
+ return NO;
+}
+
+@end
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 42e30b1417..7ff836d94f 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -449,6 +449,11 @@
CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */; };
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; };
CA1B4A512099FB2200EDD491 /* MGLMapSnapshotterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */; };
+ CA1C973E2247FD2A00CB2E04 /* MGLBackgroundIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1C973D2247FD2A00CB2E04 /* MGLBackgroundIntegrationTest.m */; };
+ CA1C9740224805B300CB2E04 /* MGLApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = CA1C973F224805B300CB2E04 /* MGLApplication.h */; };
+ CA1C9741224805B300CB2E04 /* MGLApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = CA1C973F224805B300CB2E04 /* MGLApplication.h */; };
+ CA1C974422480BD000CB2E04 /* MGLMockApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1C974322480BD000CB2E04 /* MGLMockApplication.m */; };
+ CA1C974522480BD000CB2E04 /* MGLMockApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1C974322480BD000CB2E04 /* MGLMockApplication.m */; };
CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */; };
CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; };
CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1101,6 +1106,10 @@
CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewIntegrationTest.m; sourceTree = "<group>"; wrapsLines = 0; };
CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = "<group>"; };
CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapSnapshotterTest.m; sourceTree = "<group>"; };
+ CA1C973D2247FD2A00CB2E04 /* MGLBackgroundIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLBackgroundIntegrationTest.m; sourceTree = "<group>"; };
+ CA1C973F224805B300CB2E04 /* MGLApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLApplication.h; sourceTree = "<group>"; };
+ CA1C974222480BD000CB2E04 /* MGLMockApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMockApplication.h; sourceTree = "<group>"; };
+ CA1C974322480BD000CB2E04 /* MGLMockApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMockApplication.m; sourceTree = "<group>"; };
CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCameraTransitionTests.mm; sourceTree = "<group>"; };
CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = "<group>"; };
CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = "<group>"; };
@@ -1455,6 +1464,9 @@
CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */,
077061DB215DA11F000FEF62 /* MGLTestLocationManager.h */,
077061D9215DA00E000FEF62 /* MGLTestLocationManager.m */,
+ CA1C973D2247FD2A00CB2E04 /* MGLBackgroundIntegrationTest.m */,
+ CA1C974222480BD000CB2E04 /* MGLMockApplication.h */,
+ CA1C974322480BD000CB2E04 /* MGLMockApplication.m */,
);
path = "Integration Tests";
sourceTree = "<group>";
@@ -2014,6 +2026,7 @@
DA88484A1CBAFB9800AB86E3 /* MGLMapView.mm */,
DA8848371CBAFB8500AB86E3 /* MGLMapView+IBAdditions.h */,
DA737EE01D056A4E005BDA16 /* MGLMapViewDelegate.h */,
+ CA1C973F224805B300CB2E04 /* MGLApplication.h */,
);
name = Kit;
path = src;
@@ -2416,6 +2429,7 @@
DAD1656E1CF41981001FF4B9 /* MGLFeature_Private.h in Headers */,
DA88483C1CBAFB8500AB86E3 /* MGLMapView.h in Headers */,
3EA9363147E77DD29FA06063 /* MGLRendererConfiguration.h in Headers */,
+ CA1C9740224805B300CB2E04 /* MGLApplication.h in Headers */,
55E5665121C2A1C20008B8B5 /* MMEReachability.h in Headers */,
55E5665221C2A2080008B8B5 /* MMENamespacedDependencies.h in Headers */,
55E5665321C2A2080008B8B5 /* MapboxMobileEvents.h in Headers */,
@@ -2548,6 +2562,7 @@
DA6408DC1DA4E7D300908C90 /* MGLVectorStyleLayer.h in Headers */,
353933F31D3FB753003F57D7 /* MGLCircleStyleLayer.h in Headers */,
558DE7A11E5615E400C7916D /* MGLFoundation_Private.h in Headers */,
+ CA1C9741224805B300CB2E04 /* MGLApplication.h in Headers */,
96E516F820005A3000A02306 /* MGLCompactCalloutView.h in Headers */,
96E516E22000551900A02306 /* MGLPointCollection_Private.h in Headers */,
3538AA1E1D542239008EC33D /* MGLForegroundStyleLayer.h in Headers */,
@@ -2946,8 +2961,10 @@
CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */,
CA7766842229C11A0008DE9E /* SMCalloutView.m in Sources */,
CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */,
+ CA1C974522480BD000CB2E04 /* MGLMockApplication.m in Sources */,
16376B0A1FFD9DAF0000563E /* MBGLIntegrationTests.m in Sources */,
CA88DC3021C85D900059ED5A /* MGLStyleURLIntegrationTest.m in Sources */,
+ CA1C973E2247FD2A00CB2E04 /* MGLBackgroundIntegrationTest.m in Sources */,
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */,
CA7766832229C10E0008DE9E /* MGLCompactCalloutView.m in Sources */,
CAE7AD5520F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift in Sources */,
@@ -2974,6 +2991,7 @@
DA1DC9971CB6E046006E619F /* main.m in Sources */,
354B839C1D2E9B48005D9406 /* MBXUserLocationAnnotationView.m in Sources */,
965DF51120F9430500438AAC /* MBXFrameTimeGraphView.m in Sources */,
+ CA1C974422480BD000CB2E04 /* MGLMockApplication.m in Sources */,
DA1DC9991CB6E054006E619F /* MBXAppDelegate.m in Sources */,
6FA9341721EF372100AA9CA8 /* MBXOrnamentsViewController.m in Sources */,
DA1DC96B1CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m in Sources */,
diff --git a/platform/ios/src/MGLApplication.h b/platform/ios/src/MGLApplication.h
new file mode 100644
index 0000000000..a321224c2a
--- /dev/null
+++ b/platform/ios/src/MGLApplication.h
@@ -0,0 +1,16 @@
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol MGLApplication <NSObject>
+@property(nonatomic, readonly) UIApplicationState applicationState;
+@property(nonatomic, nullable, assign) id<UIApplicationDelegate> delegate;
+@property(nonatomic, readonly) UIInterfaceOrientation statusBarOrientation __TVOS_PROHIBITED;
+
+// TODO: support openURL:options:completionHandler:
+- (BOOL)openURL:(NSURL*)url NS_DEPRECATED_IOS(2_0, 10_0, "Please use openURL:options:completionHandler: instead") NS_EXTENSION_UNAVAILABLE_IOS("");
+@end
+
+NS_ASSUME_NONNULL_END
+
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index bbce6be961..c0b9810678 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -74,6 +74,7 @@
#import "MGLMapAccessibilityElement.h"
#import "MGLLocationManager_Private.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLApplication.h"
#include <algorithm>
#include <cstdlib>
@@ -191,6 +192,10 @@ public:
NSString *viewReuseIdentifier;
};
+@interface UIApplication (MGLApplicationConforming) <MGLApplication>
+@end
+
+
#pragma mark - Private -
@interface MGLMapView () <UIGestureRecognizerDelegate,
@@ -269,6 +274,12 @@ public:
@property (nonatomic) MGLMapDebugMaskOptions residualDebugMask;
@property (nonatomic, copy) NSURL *residualStyleURL;
+// Application properties
+@property (nonatomic) id<MGLApplication> application;
+@property (nonatomic) BOOL rendererWasFlushed;
+@property (nonatomic) CADisplayLink *displayLink;
+
+
- (mbgl::Map &)mbglMap;
@end
@@ -303,7 +314,6 @@ public:
CLLocationDegrees _pendingLatitude;
CLLocationDegrees _pendingLongitude;
- CADisplayLink *_displayLink;
BOOL _needsDisplayRefresh;
NSInteger _changeDelimiterSuppressionDepth;
@@ -441,12 +451,42 @@ public:
return _rendererFrontend->getRenderer();
}
+- (void)setApplication:(id<MGLApplication>)application
+{
+ if (application != _application)
+ {
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ if (_application) {
+ [center removeObserver:self name:UIApplicationWillResignActiveNotification object:_application];
+ [center removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:_application];
+ [center removeObserver:self name:UIApplicationWillEnterForegroundNotification object:_application];
+ [center removeObserver:self name:UIApplicationDidBecomeActiveNotification object:_application];
+ [center removeObserver:self name:UIApplicationWillTerminateNotification object:_application];
+ [center removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:_application];
+ }
+
+ _application = application;
+
+ if (application) {
+ [center addObserver:self selector:@selector(willResignActive:) name:UIApplicationWillResignActiveNotification object:application];
+ [center addObserver:self selector:@selector(sleepGL:) name:UIApplicationDidEnterBackgroundNotification object:application];
+ [center addObserver:self selector:@selector(wakeGL:) name:UIApplicationWillEnterForegroundNotification object:application];
+ [center addObserver:self selector:@selector(wakeGL:) name:UIApplicationDidBecomeActiveNotification object:application];
+ [center addObserver:self selector:@selector(willTerminate) name:UIApplicationWillTerminateNotification object:application];
+ [center addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:application];
+
+ }
+ }
+}
+
- (void)commonInit
{
+ [self setApplication:[UIApplication sharedApplication]];
+
_opaque = NO;
_atLeastiOS_12_2_0 = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){12,2,0}];
- BOOL background = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
+ BOOL background = _application.applicationState == UIApplicationStateBackground;
if (!background)
{
[self createGLView];
@@ -632,17 +672,6 @@ public:
[_singleTapGestureRecognizer requireGestureRecognizerToFail:_quickZoom];
[self addGestureRecognizer:_singleTapGestureRecognizer];
- // observe app activity
- //
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willTerminate) name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sleepGL:) name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationWillEnterForegroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationDidBecomeActiveNotification object:nil];
- // As of 3.7.5, we intentionally do not listen for `UIApplicationWillResignActiveNotification` or call `sleepGL:` in response to it, as doing
- // so causes a loop when asking for location permission. See: https://github.com/mapbox/mapbox-gl-native/issues/11225
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
-
// Device orientation management
self.currentOrientation = UIInterfaceOrientationUnknown;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
@@ -1465,6 +1494,10 @@ public:
[self setNeedsLayout];
}
+- (void)willResignActive:(__unused NSNotification *)notification
+{
+}
+
- (void)sleepGL:(__unused NSNotification *)notification
{
// If this view targets an external display, such as AirPlay or CarPlay, we
@@ -1525,7 +1558,7 @@ public:
MGLLogInfo(@"Entering foreground.");
MGLAssertIsMainThread();
- if (self.dormant && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground)
+ if (self.dormant && self.application.applicationState != UIApplicationStateBackground)
{
self.dormant = NO;
@@ -2398,7 +2431,7 @@ public:
direction:camera.heading
pitch:camera.pitch];
}
- [[UIApplication sharedApplication] openURL:url];
+ [self.application openURL:url];
}
}];
[attributionController addAction:action];
@@ -2453,7 +2486,7 @@ public:
UIAlertAction *moreAction = [UIAlertAction actionWithTitle:moreTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.mapbox.com/telemetry/"]];
+ [self.application openURL:[NSURL URLWithString:@"https://www.mapbox.com/telemetry/"]];
}];
[alertController addAction:moreAction];
@@ -5604,7 +5637,7 @@ public:
if (self.userTrackingMode == MGLUserTrackingModeNone &&
self.userLocationAnnotationView.accessibilityElementIsFocused &&
- [UIApplication sharedApplication].applicationState == UIApplicationStateActive)
+ self.application.applicationState == UIApplicationStateActive)
{
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.userLocationAnnotationView);
}
@@ -5868,7 +5901,7 @@ public:
// note that right/left device and interface orientations are opposites (see UIApplication.h)
//
CLDeviceOrientation orientation;
- switch ([[UIApplication sharedApplication] statusBarOrientation])
+ switch ([self.application statusBarOrientation])
{
case (UIInterfaceOrientationLandscapeLeft):
{
@@ -6115,7 +6148,7 @@ public:
BOOL respondsToSelectorWithReason = [self.delegate respondsToSelector:@selector(mapView:regionDidChangeWithReason:animated:)];
if ((respondsToSelector || respondsToSelectorWithReason) &&
- ([UIApplication sharedApplication].applicationState == UIApplicationStateActive))
+ (self.application.applicationState == UIApplicationStateActive))
{
_featureAccessibilityElements = nil;
_visiblePlaceFeatures = nil;