diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-06-01 15:23:41 -0700 |
---|---|---|
committer | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-06-07 17:43:41 -0400 |
commit | 58b0faef55a3d75a8e4463156fb045c0e2bb7341 (patch) | |
tree | 0cc9d5097e14923d72c25cbb0c84b5ae64282796 | |
parent | 94ad8a6c7ef87b2dcad79ac570f9ce8651812f6f (diff) | |
download | qtlocation-mapboxgl-58b0faef55a3d75a8e4463156fb045c0e2bb7341.tar.gz |
[ios, test] Add MGLMapSnapshotter integration tests.
# Conflicts:
# platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m
3 files changed, 29 insertions, 9 deletions
diff --git a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h index 3ceec8f04a..1b680f2b71 100644 --- a/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h +++ b/platform/ios/Integration Tests/MGLMapViewIntegrationTest.h @@ -10,6 +10,12 @@ #define MGLTestAssertEqualWithAccuracy(myself, expression1, expression2, accuracy, ...) \ _XCTPrimitiveAssertEqualWithAccuracy(myself, expression1, @#expression1, expression2, @#expression2, accuracy, @#accuracy, __VA_ARGS__) +#define MGLTestAssertNil(myself, expression, ...) \ + _XCTPrimitiveAssertNil(myself, expression, @#expression, __VA_ARGS__) + +#define MGLTestAssertNotNil(myself, expression, ...) \ + _XCTPrimitiveAssertNotNil(myself, expression, @#expression, __VA_ARGS__) + @interface MGLMapViewIntegrationTest : XCTestCase <MGLMapViewDelegate> @property (nonatomic) MGLMapView *mapView; diff --git a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m index 6a698121c9..f31f9cf787 100644 --- a/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m +++ b/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterTest.m @@ -104,11 +104,12 @@ NSString* validAccessToken() { [self waitForExpectations:@[expectation] timeout:2.0]; } -- (void)testSnapshotterFromBackgroundQueue { +- (void)testMultipleSnapshottersFromBackgroundQueue { if (!validAccessToken()) { return; } + // Crashes with only 1 snapshot CGSize size = self.mapView.bounds.size; CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(30.0, 30.0); @@ -144,9 +145,10 @@ NSString* validAccessToken() { MGLTestAssertNotNil(strongself, snapshot.image); MGLTestAssertNil(strongself, error, @"Snapshot should not error with: %@", error); - // Change this to XCTAttachmentLifetimeKeepAlways to be able to look at the snapshots after running + // Change this back to XCTAttachmentLifetimeDeleteOnSuccess when we're sure this + // test is passing. XCTAttachment *attachment = [XCTAttachment attachmentWithImage:snapshot.image]; - attachment.lifetime = XCTAttachmentLifetimeDeleteOnSuccess; + attachment.lifetime = XCTAttachmentLifetimeKeepAlways; [strongself addAttachment:attachment]; dispatch_group_leave(group); @@ -172,11 +174,10 @@ NSString* validAccessToken() { }); }); - [self waitForExpectations:@[expectation] timeout:60.0]; + [self waitForExpectations:@[expectation] timeout:10.0]; } -- (void)testMultipleSnapshottersPENDING { - MGL_CHECK_IF_PENDING_TEST_SHOULD_RUN(); +- (void)testMultipleSnapshotters { if (!validAccessToken()) { return; } @@ -216,9 +217,10 @@ NSString* validAccessToken() { MGLTestAssertNotNil(strongself, snapshot.image); MGLTestAssertNil(strongself, error, @"Snapshot should not error with: %@", error); - // Change this to XCTAttachmentLifetimeKeepAlways to be able to look at the snapshots after running + // Change this back to XCTAttachmentLifetimeDeleteOnSuccess when we're sure this + // test is passing. XCTAttachment *attachment = [XCTAttachment attachmentWithImage:snapshot.image]; - attachment.lifetime = XCTAttachmentLifetimeDeleteOnSuccess; + attachment.lifetime = XCTAttachmentLifetimeKeepAlways; [strongself addAttachment:attachment]; // Dealloc the snapshotter (by having this line in the block, we @@ -231,7 +233,7 @@ NSString* validAccessToken() { }]; } // end for loop - [self waitForExpectations:@[expectation] timeout:60.0]; + [self waitForExpectations:@[expectation] timeout:20.0]; } @end diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index c0909344f3..1df509f477 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -365,6 +365,7 @@ AC518E04201BB56100EBC820 /* MGLTelemetryConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = AC518DFE201BB55A00EBC820 /* MGLTelemetryConfig.m */; }; 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 */; }; CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; }; CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */; }; CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1001,6 +1002,7 @@ CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLShapeSourceTests.m; sourceTree = "<group>"; }; CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewIntegrationTest.m; sourceTree = "<group>"; }; 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>"; }; CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = "<group>"; }; CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCameraTransitionTests.mm; sourceTree = "<group>"; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = "<group>"; }; @@ -1356,6 +1358,7 @@ 16376B081FFD9DAF0000563E /* Integration Tests */ = { isa = PBXGroup; children = ( + CA1B4A4F2099FA2800EDD491 /* Snapshotter Tests */, 16376B091FFD9DAF0000563E /* MBGLIntegrationTests.m */, 16376B0B1FFD9DAF0000563E /* Info.plist */, CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */, @@ -1708,6 +1711,14 @@ name = Fixtures; sourceTree = "<group>"; }; + CA1B4A4F2099FA2800EDD491 /* Snapshotter Tests */ = { + isa = PBXGroup; + children = ( + CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */, + ); + path = "Snapshotter Tests"; + sourceTree = "<group>"; + }; DA1DC9411CB6C1C2006E619F = { isa = PBXGroup; children = ( @@ -2821,6 +2832,7 @@ 16376B0A1FFD9DAF0000563E /* MBGLIntegrationTests.m in Sources */, CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */, CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */, + CA1B4A512099FB2200EDD491 /* MGLMapSnapshotterTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |