-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Test map view within tab bar controller #14704
Conversation
@@ -84,6 +84,11 @@ | |||
"idiom" : "ipad", | |||
"size" : "83.5x83.5", | |||
"scale" : "2x" | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to do: remove this.
}]; | ||
}); | ||
|
||
[self waitForExpectationsWithTimeout:10 handler:^(NSError * _Nullable error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: timing based tests taking much, much longer than expected are why the Integration Tests target isn’t run on CI. Even though we’re not expecting to make these tests run on virtualized CI again, reducing their dependency on timing is always something to strive towards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! After talking to @julianrex, I'm going to take a different approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still using the timer, but that is because I am not sure if there's another way to prevent the test from ending early.
It looks like |
8506a76
to
58ce1ec
Compare
I have rebased this on |
@@ -2992,40 +3006,40 @@ | |||
/* End PBXResourcesBuildPhase section */ | |||
|
|||
/* Begin PBXShellScriptBuildPhase section */ | |||
074A7F0B2277BD67001A62D1 /* Insert Mapbox Access Token */ = { | |||
07796BA2227908CB0059CAF1 /* Insert Mapbox Access Token */ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to do: I should remove this script, it doesn't matter 😅
@implementation MBXTestMapView | ||
|
||
- (void)updateFromDisplayLink:(CADisplayLink*)displayLink { | ||
[super updateFromDisplayLink:displayLink]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment this isn't doing anything. This is what we need to time, and we should assert if the time diff is >= 1 second.
[self.window setRootViewController:(UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"TabController"]]; | ||
|
||
// Access the tab controller from the story board, then access one of the childViewControllers. | ||
self.tabController = (UITabBarController *)self.window.rootViewController; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be tempted to set up tabController
before you set the root view controller.
self.tabController = (UITabBarController *)self.window.rootViewController; | ||
self.viewController = self.tabController.childViewControllers[0]; | ||
|
||
[self.viewController.view addSubview:self.mapView]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to look at the view sizes, and potentially the resizing masks/constraints.
[self.mapView addAnnotation:annot]; | ||
} | ||
|
||
- (void)testViewControllerNil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate tests are completely new instances, so I think you could move this test into the main one below.
XCTestExpectation *expectation = [self expectationWithDescription:@"Able to switch the tabs repeatedly without lag"]; | ||
__block NSInteger counter = 0; | ||
|
||
__block NSTimer *repeatingTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer * _Nonnull timer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pair on this block - not sure what we need to do here.
counter++; | ||
NSLog(@"%li", counter); | ||
self.tabController.selectedIndex = counter % 2; | ||
if (counter > 41) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 41
? Is this a Douglas Adams reference??
repeatingTimer = nil; | ||
|
||
MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:CLLocationCoordinate2DMake(10, 10) altitude:100 pitch:0 heading:0]; | ||
[self.mapView flyToCamera:camera withDuration:4 completionHandler:^{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should happen at the start of the timer?
[expectation fulfill]; | ||
}]; | ||
|
||
[self measureBlock:^{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need to call updateFromDisplayLink
the waitForExpectations:..
below should handle that IIRC.
I hadn't considered using measureBlock
- that's an interesting idea - but I don't think it's appropriate here.
This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This pull request has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
Adds tests for #14232 Part of ongoing work related to #14654,
I'm currently exploring how to detect that the map itself has become unresponsive. Currently planning to move the map after the timer has run for a few seconds, then check whether the map's center has changed.
cc @julianrex