summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-04-23 14:46:50 -0400
committerJulian Rex <julian.rex@mapbox.com>2018-05-21 13:05:04 -0400
commit11b8eb80e3192ba9c91787e34d30144f2c5fbded (patch)
tree58b75647fb734f144070faff37a41faf2af2ba78
parentaa6c1e5734466edb0cf2c248c9af4fea64e0c7da (diff)
downloadqtlocation-mapboxgl-11b8eb80e3192ba9c91787e34d30144f2c5fbded.tar.gz
Adjusted wait periods (based on documented durations) to reduce test times.
-rw-r--r--platform/ios/Integration Tests/MGLCameraTransitionTests.mm (renamed from platform/ios/Integration Tests/MGLCameraTransitionTests.m)37
-rw-r--r--platform/ios/Integration Tests/MGLShapeSourceTests.m10
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj12
-rw-r--r--src/mbgl/map/transform.cpp10
4 files changed, 46 insertions, 23 deletions
diff --git a/platform/ios/Integration Tests/MGLCameraTransitionTests.m b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm
index 4cce195e7c..c8cc57e0b2 100644
--- a/platform/ios/Integration Tests/MGLCameraTransitionTests.m
+++ b/platform/ios/Integration Tests/MGLCameraTransitionTests.mm
@@ -1,4 +1,5 @@
#import "MGLMapViewIntegrationTest.h"
+#import "../../darwin/src/MGLGeometry_Private.h"
@interface MBCameraTransitionTests : MGLMapViewIntegrationTest
@end
@@ -28,13 +29,13 @@
}
[NSObject cancelPreviousPerformRequestsWithTarget:expectation selector:@selector(fulfill) object:nil];
- [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:5.0];
+ [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:0.5];
};
[self.mapView setDirection:90 animated:YES];
// loop, render, and wait
- [self waitForExpectations:@[expectation] timeout:10.0];
+ [self waitForExpectations:@[expectation] timeout:1.5];
XCTAssert(delegateCallCount == 2, @"Expecting 2 regionDidChange callbacks, got %ld", delegateCallCount); // Once for the setDirection and once for the reset north
}
@@ -62,11 +63,11 @@
}
[NSObject cancelPreviousPerformRequestsWithTarget:expectation selector:@selector(fulfill) object:nil];
- [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:5.0];
+ [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:0.5];
};
[self.mapView setDirection:90 animated:YES];
- [self waitForExpectations:@[expectation] timeout:10.0];
+ [self waitForExpectations:@[expectation] timeout:1.5];
XCTAssert(delegateCallCount == 2, @"Expecting 2 regionDidChange callbacks, got %ld", delegateCallCount); // Once for the setDirection and once for the reset north
}
@@ -145,6 +146,7 @@
@"center coordinate latitude should be at target");
// Now set another coordinate.
+ // Should take MGLAnimationDuration seconds (0.3s)
[mapView setCenterCoordinate:target2 animated:YES];
break;
}
@@ -176,11 +178,12 @@
delegateCallCount++;
[NSObject cancelPreviousPerformRequestsWithTarget:expectation selector:@selector(fulfill) object:nil];
- [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:5.0];
+ [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:0.5];
};
+ // Should take MGLAnimationDuration seconds (0.3)
[self.mapView setCenterCoordinate:target zoomLevel:15.0 animated:YES];
- [self waitForExpectations:@[expectation] timeout:10.0];
+ [self waitForExpectations:@[expectation] timeout:1.5];
XCTAssert(delegateCallCount == 2, @"Expecting 2 regionDidChange callbacks, got %ld", delegateCallCount); // Once for the setDirection and once for the reset north
}
@@ -193,10 +196,17 @@
__block NSInteger delegateCallCount = 0;
CLLocationCoordinate2D target = CLLocationCoordinate2DMake(40.0, 40.0);
- CLLocationCoordinate2D target2 = CLLocationCoordinate2DMake(-40.0, -40.0);
+ CLLocationCoordinate2D target2 = CLLocationCoordinate2DMake(30.0, 30.0);
__block BOOL runloop = YES;
+ NSTimeInterval stop0 = CACurrentMediaTime();
+ __block NSTimeInterval stop1 = 0.0;
+ __block NSTimeInterval stop2 = 0.0;
+
+ double zoomLevel = 5.0;
+ double altitude = MGLAltitudeForZoomLevel(zoomLevel, 0.0, target.latitude, self.mapView.frame.size);
+
self.regionDidChange = ^(MGLMapView *mapView, MGLCameraChangeReason reason, BOOL animated) {
MBCameraTransitionTests *strongSelf = weakself;
@@ -210,6 +220,8 @@
switch(delegateCallCount) {
case 0:
{
+ stop1 = CACurrentMediaTime();
+
// Our center coordinate should match our target (assuming we're not
// constrained by zoom level)
MGLTestAssertEqualWithAccuracy(strongSelf,
@@ -226,13 +238,15 @@
// Now set another coordinate.
MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:target2
- fromDistance:10
+ fromDistance:altitude
pitch:0.0
heading:0.0];
+ // flyToCamera can take a while...
[mapView flyToCamera:camera completionHandler:^{
MGLTestAssert(strongSelf, !runloop, @"Completion block should be called after delegate method");
[expectation fulfill];
+ stop2 = CACurrentMediaTime();
}];
break;
}
@@ -265,14 +279,17 @@
delegateCallCount++;
};
- [self.mapView setCenterCoordinate:target zoomLevel:15.0 animated:YES];
+ // Should take MGLAnimationDuration
+ [self.mapView setCenterCoordinate:target zoomLevel:zoomLevel animated:YES];
// Run the loop, so the camera can fly to the new camera
while (runloop) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
+ [self waitForExpectations:@[expectation] timeout:0.5];
- [self waitForExpectations:@[expectation] timeout:1.0];
+ NSLog(@"setCenterCoordinate: %0.4fs", stop1 - stop0);
+ NSLog(@"flyToCamera: %0.4fs", stop2 - stop1);
XCTAssert(delegateCallCount == 2, @"Expecting 2 regionDidChange callbacks, got %ld", delegateCallCount); // Once for the setDirection and once for the reset north
}
diff --git a/platform/ios/Integration Tests/MGLShapeSourceTests.m b/platform/ios/Integration Tests/MGLShapeSourceTests.m
index 83fade215a..7eb7c453cc 100644
--- a/platform/ios/Integration Tests/MGLShapeSourceTests.m
+++ b/platform/ios/Integration Tests/MGLShapeSourceTests.m
@@ -63,11 +63,12 @@
}
[NSObject cancelPreviousPerformRequestsWithTarget:expectation selector:@selector(fulfill) object:nil];
- [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:5.0];
+ [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:0.5];
};
+ // setCenterCoordinate is NOT animated here.
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(10.0, 10.0)];
- [self waitForExpectations:@[expectation] timeout:30.0];
+ [self waitForExpectations:@[expectation] timeout:5.0];
}
- (void)testSettingShapeSourceToNilInRegionIsChanging {
@@ -111,11 +112,12 @@
}
[NSObject cancelPreviousPerformRequestsWithTarget:expectation selector:@selector(fulfill) object:nil];
- [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:1.0];
+ [expectation performSelector:@selector(fulfill) withObject:nil afterDelay:0.5];
};
+ // Should take MGLAnimationDuration seconds (0.3)
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(10.0, 10.0) animated:YES];
- [self waitForExpectations:@[expectation] timeout:30.0];
+ [self waitForExpectations:@[expectation] timeout:1.0];
}
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index ad7bc29e8f..aef2552b0b 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -366,7 +366,7 @@
CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */; };
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; };
CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; };
- CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.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, ); }; };
CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; };
CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; };
@@ -1002,7 +1002,7 @@
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>"; };
CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = "<group>"; };
- CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCameraTransitionTests.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>"; };
DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; };
DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; };
@@ -1357,7 +1357,7 @@
children = (
16376B091FFD9DAF0000563E /* MBGLIntegrationTests.m */,
16376B0B1FFD9DAF0000563E /* Info.plist */,
- CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.m */,
+ CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */,
CA0C27912076C804001CE5B7 /* MGLShapeSourceTests.m */,
CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */,
CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */,
@@ -2815,7 +2815,7 @@
buildActionMask = 2147483647;
files = (
CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */,
- CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.m in Sources */,
+ CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */,
16376B0A1FFD9DAF0000563E /* MBGLIntegrationTests.m in Sources */,
CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */,
CA0C27922076C804001CE5B7 /* MGLShapeSourceTests.m in Sources */,
@@ -3387,6 +3387,7 @@
/* Begin XCBuildConfiguration section */
16376B0E1FFD9DAF0000563E /* Debug */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -3401,6 +3402,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
+ HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = "Integration Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.integration-tests";
@@ -3412,6 +3414,7 @@
};
16376B0F1FFD9DAF0000563E /* Release */ = {
isa = XCBuildConfiguration;
+ baseConfigurationReference = 55D8C9941D0F133500F42F10 /* config.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
@@ -3426,6 +3429,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
+ HEADER_SEARCH_PATHS = "$(mbgl_core_INCLUDE_DIRECTORIES)";
INFOPLIST_FILE = "Integration Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.mapbox.integration-tests";
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 1e5793ccbc..79815d9398 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -612,8 +612,8 @@ void Transform::startTransition(const CameraOptions& camera,
};
if (!isAnimated) {
- auto update = transitionFrameFn;
- auto finish = transitionFinishFn;
+ auto update = std::move(transitionFrameFn);
+ auto finish = std::move(transitionFinishFn);
transitionFrameFn = nullptr;
transitionFinishFn = nullptr;
@@ -640,13 +640,13 @@ void Transform::updateTransitions(const TimePoint& now) {
// By temporarily nulling the `transitionFrameFn` (and then restoring it
// after the temporary has been called) we stop this recursion.
- auto transition = transitionFrameFn;
+ auto transition = std::move(transitionFrameFn);
transitionFrameFn = nullptr;
if (transition && transition(now)) {
// If the transition indicates that it is complete, then we should call
// the finish lambda (going via a temporary as above)
- auto finish = transitionFinishFn;
+ auto finish = std::move(transitionFinishFn);
transitionFinishFn = nullptr;
transitionFrameFn = nullptr;
@@ -656,7 +656,7 @@ void Transform::updateTransitions(const TimePoint& now) {
}
}
else {
- transitionFrameFn = transition;
+ transitionFrameFn = std::move(transition);
}
}