Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] testing out tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkiley committed Jul 13, 2018
1 parent d2bb6c2 commit dcd0d75
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions platform/ios/test/MGLAnnotationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,34 @@ - (void)setUp
[super setUp];
_mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
_mapView.delegate = self;
_mapView.accessibilityIdentifier = @"Map View";
_mapView.accessibilityLabel = @"Map View";
}

- (void)testTappingDisabledPolyline {

CLLocationCoordinate2D coordinates[] = {
_mapView.visibleCoordinateBounds.ne,
_mapView.centerCoordinate,
_mapView.visibleCoordinateBounds.sw
};

MGLPolyline *polyline = [MGLPolyline polylineWithCoordinates:coordinates count:3];
polyline.enabled = NO;
polyline.accessibilityLabel = @"Polyline";
[_mapView addAnnotation:polyline];

// Code to simulate tap
// Getting
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *element =
XCUIElement *mapElement = [[app descendantsMatchingType:XCUIElementTypeAny] elementMatchingPredicate:[NSPredicate predicateWithFormat:@"accessibilityLabel == 'Map View'"]];
// XCUIElement *lineElement = [[app descendantsMatchingType:XCUIElementTypeAny] elementMatchingPredicate:[NSPredicate predicateWithFormat:@"accessibilityLabel == 'Polyline'"]];

CGPoint point = [_mapView convertCoordinate:_mapView.centerCoordinate toPointToView:_mapView];

XCUICoordinate *center = [mapElement coordinateWithNormalizedOffset:CGVectorMake(point.x, point.y)];
[center tap];

XCTAssertNil(_mapView.selectedAnnotations.firstObject, @"There should be no selected annotation");
}

@end

0 comments on commit dcd0d75

Please sign in to comment.