This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios] Add UI Testing to Integration Tests
- Loading branch information
jmkiley
committed
Jul 13, 2018
1 parent
dcd0d75
commit c297443
Showing
6 changed files
with
288 additions
and
49 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
platform/ios/Integration Tests/MGLAnnotationIntegrationTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// | ||
// MGLAnnotationIntegrationTests.m | ||
// MGLUITests | ||
// | ||
// Created by Jordan on 7/13/18. | ||
// Copyright © 2018 Mapbox. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "MGLMapViewIntegrationTest.h" | ||
#import "MGLTestUtility.h" | ||
|
||
@interface MGLAnnotationIntegrationTests : XCTestCase <MGLMapViewDelegate> | ||
@property (nonatomic) XCTestExpectation *expectation; | ||
@property (nonatomic) MGLMapView *mapView; | ||
@end | ||
|
||
@implementation MGLAnnotationIntegrationTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
_mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)]; | ||
_mapView.delegate = self; | ||
_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 "NSInternalInconsistencyException", "No target application path specified via test configuration: ..." | ||
XCUIApplication *app = [[XCUIApplication alloc] init]; | ||
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 | ||
|
||
//@interface MGLAnnotationIntegrationTests : XCTestCase | ||
// | ||
//@end | ||
// | ||
//@implementation MGLAnnotationIntegrationTests | ||
// | ||
//- (void)setUp { | ||
// [super setUp]; | ||
// | ||
// // Put setup code here. This method is called before the invocation of each test method in the class. | ||
// | ||
// // In UI tests it is usually best to stop immediately when a failure occurs. | ||
// self.continueAfterFailure = NO; | ||
// // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. | ||
// [[[XCUIApplication alloc] init] launch]; | ||
// | ||
// // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. | ||
//} | ||
// | ||
//- (void)tearDown { | ||
// // Put teardown code here. This method is called after the invocation of each test method in the class. | ||
// [super tearDown]; | ||
//} | ||
// | ||
//- (void)testExample { | ||
// // Use recording to get started writing UI tests. | ||
// // Use XCTAssert and related functions to verify your tests produce the correct results. | ||
//} | ||
// | ||
//@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// MGLUITests.m | ||
// MGLUITests | ||
// | ||
// Created by Jordan on 7/13/18. | ||
// Copyright © 2018 Mapbox. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
@interface MGLUITests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation MGLUITests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
|
||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
|
||
// In UI tests it is usually best to stop immediately when a failure occurs. | ||
self.continueAfterFailure = NO; | ||
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. | ||
[[[XCUIApplication alloc] init] launch]; | ||
|
||
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testExample { | ||
// Use recording to get started writing UI tests. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
|
||
@end |
Oops, something went wrong.