summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-26 17:12:42 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-05-05 01:07:29 -0700
commitf4ce3e272897b293a62ce8b301061e10ee809691 (patch)
tree6524e2bf7f84775abcce6f1725ae8e5da3831440
parent24f1688a7411f9541a883bc03bf17107dd7e0e85 (diff)
downloadqtlocation-mapboxgl-f4ce3e272897b293a62ce8b301061e10ee809691.tar.gz
[ios] Refactored UI test cases
All the test cases now inherit from a single XCTestCase subclass that implements the pre-test cleanup procedure.
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj8
-rw-r--r--platform/ios/uitest/MGLAnnotationTests.m30
-rw-r--r--platform/ios/uitest/MGLGestureTests.m23
-rw-r--r--platform/ios/uitest/MGLTelemetryTests.m19
-rw-r--r--platform/ios/uitest/MGLUITestCase.h5
-rw-r--r--platform/ios/uitest/MGLUITestCase.m23
-rw-r--r--platform/ios/uitest/MGLUITests.h3
7 files changed, 43 insertions, 68 deletions
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index a05162bed1..d93aa362e6 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -226,6 +226,7 @@
DABFB8731CBE9A9900D62B32 /* Mapbox.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */; settings = {ATTRIBUTES = (Public, ); }; };
DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */; };
DAC49C5D1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */; };
+ DAC49C611CD03A96009E1AA3 /* MGLUITestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC49C601CD03A96009E1AA3 /* MGLUITestCase.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -360,7 +361,7 @@
DA4A0DF11CCE82500045352A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DA4A26961CB6E795000B7809 /* Mapbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Mapbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA6A65961CCF429800F21F6B /* MGLGestureTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLGestureTests.m; sourceTree = "<group>"; };
- DA6A65981CCF42FE00F21F6B /* MGLUITests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUITests.h; sourceTree = "<group>"; };
+ DA6A65981CCF42FE00F21F6B /* MGLUITestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUITestCase.h; sourceTree = "<group>"; };
DA6A65B81CCF5DB900F21F6B /* MGLTelemetryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLTelemetryTests.m; sourceTree = "<group>"; };
DA821D041CCC6D59007508D4 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
DA821D051CCC6D59007508D4 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
@@ -479,6 +480,7 @@
DABCABC01CB80717000A7C39 /* locations.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = locations.hpp; sourceTree = "<group>"; };
DAC07C961CBB2CD6000CB309 /* mbgl.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = mbgl.xcconfig; path = ../../build/ios/mbgl.xcconfig; sourceTree = "<group>"; };
DAC49C621CD07D74009E1AA3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
+ DAC49C601CD03A96009E1AA3 /* MGLUITestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUITestCase.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -642,7 +644,8 @@
DA4A0DEE1CCE82500045352A /* UI Tests */ = {
isa = PBXGroup;
children = (
- DA6A65981CCF42FE00F21F6B /* MGLUITests.h */,
+ DA6A65981CCF42FE00F21F6B /* MGLUITestCase.h */,
+ DAC49C601CD03A96009E1AA3 /* MGLUITestCase.m */,
DA4A0DEF1CCE82500045352A /* MGLAnnotationTests.m */,
DA6A65961CCF429800F21F6B /* MGLGestureTests.m */,
DA6A65B81CCF5DB900F21F6B /* MGLTelemetryTests.m */,
@@ -1309,6 +1312,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ DAC49C611CD03A96009E1AA3 /* MGLUITestCase.m in Sources */,
DA6A65971CCF429800F21F6B /* MGLGestureTests.m in Sources */,
DA6A65B91CCF5DB900F21F6B /* MGLTelemetryTests.m in Sources */,
DA4A0DF01CCE82500045352A /* MGLAnnotationTests.m in Sources */,
diff --git a/platform/ios/uitest/MGLAnnotationTests.m b/platform/ios/uitest/MGLAnnotationTests.m
index 9798647204..38e22ad428 100644
--- a/platform/ios/uitest/MGLAnnotationTests.m
+++ b/platform/ios/uitest/MGLAnnotationTests.m
@@ -1,31 +1,11 @@
-#import "MGLUITests.h"
+#import "MGLUITestCase.h"
-@interface MGLAnnotationTests : XCTestCase
+@interface MGLAnnotationTests : MGLUITestCase
@end
@implementation MGLAnnotationTests
-- (void)setUp {
- [super setUp];
-
- self.continueAfterFailure = NO;
-
- [XCUIDevice sharedDevice].orientation = UIDeviceOrientationPortrait;
- XCUIApplication *app = [[XCUIApplication alloc] init];
-
- // Bypass the access token prompt.
- NSMutableDictionary <NSString *, NSString *> *environment = app.launchEnvironment.mutableCopy;
- environment[@"MAPBOX_ACCESS_TOKEN"] = MGLUITestsBogusAccessToken;
- app.launchEnvironment = environment;
-
- [app launch];
-
- // Reset the viewport.
- [app.navigationBars[@"MBXNavigationBar"].buttons[@"MBXSettingsButton"] tap];
- [app.sheets[@"Map Settings"].collectionViews.buttons[@"Reset Position"] tap];
-}
-
- (void)testDropPin {
XCUIElement *mapElement = [[XCUIApplication alloc] init].otherElements[@"MGLMapView"];
NSPredicate *exists = [NSPredicate predicateWithFormat:@"exists == YES"];
@@ -116,7 +96,7 @@
NSPredicate *isAbsent = [NSPredicate predicateWithFormat:@"exists == NO"];
// Drop a pin.
- XCUIElement *mapElement = [[XCUIApplication alloc] init].otherElements[@"MGLMapView"];
+ XCUIElement *mapElement = app.otherElements[@"MGLMapView"];
XCUIElement *mapProxyElement = mapElement.buttons[@"MGLMapViewProxyAccessibilityElement"];
[self expectationForPredicate:exists evaluatedWithObject:mapProxyElement handler:nil];
[mapElement pressForDuration:1.1];
@@ -138,7 +118,7 @@
[app.navigationBars[@"MBXNavigationBar"].buttons[@"MBXSettingsButton"] tap];
// Add 100 points.
- XCUIElement *mapElement = [[XCUIApplication alloc] init].otherElements[@"MGLMapView"];
+ XCUIElement *mapElement = app.otherElements[@"MGLMapView"];
XCUIElement *lastAnnotationElement = mapElement.buttons[@"MGLMapViewAnnotation 99"];
[self expectationForPredicate:exists evaluatedWithObject:lastAnnotationElement handler:nil];
[app.sheets[@"Map Settings"].collectionViews.buttons[@"Add 100 Points"] tap];
@@ -153,7 +133,7 @@
[app.navigationBars[@"MBXNavigationBar"].buttons[@"MBXSettingsButton"] tap];
// Start the world tour.
- XCUIElement *mapElement = [[XCUIApplication alloc] init].otherElements[@"MGLMapView"];
+ XCUIElement *mapElement = app.otherElements[@"MGLMapView"];
[self expectationForPredicate:exists evaluatedWithObject:mapElement.buttons[@"Washington, D.C."] handler:nil];
[app.sheets[@"Map Settings"].collectionViews.buttons[@"Start World Tour"] tap];
[self waitForExpectationsWithTimeout:5 handler:nil];
diff --git a/platform/ios/uitest/MGLGestureTests.m b/platform/ios/uitest/MGLGestureTests.m
index 42199dc20d..c9abd2f4f4 100644
--- a/platform/ios/uitest/MGLGestureTests.m
+++ b/platform/ios/uitest/MGLGestureTests.m
@@ -1,30 +1,11 @@
-#import "MGLUITests.h"
+#import "MGLUITestCase.h"
-@interface MGLGestureTests : XCTestCase
+@interface MGLGestureTests : MGLUITestCase
@end
@implementation MGLGestureTests
-- (void)setUp {
- [super setUp];
-
- self.continueAfterFailure = NO;
- [XCUIDevice sharedDevice].orientation = UIDeviceOrientationPortrait;
- XCUIApplication *app = [[XCUIApplication alloc] init];
-
- // Bypass the access token prompt.
- NSMutableDictionary <NSString *, NSString *> *environment = app.launchEnvironment.mutableCopy;
- environment[@"MAPBOX_ACCESS_TOKEN"] = MGLUITestsBogusAccessToken;
- app.launchEnvironment = environment;
-
- [app launch];
-
- // Reset the viewport.
- [app.navigationBars[@"MBXNavigationBar"].buttons[@"MBXSettingsButton"] tap];
- [app.sheets[@"Map Settings"].collectionViews.buttons[@"Reset Position"] tap];
-}
-
- (void)testRotate {
XCUIElement *mapElement = [[XCUIApplication alloc] init].otherElements[@"MGLMapView"];
XCUIElement *compassElement = mapElement.buttons[@"MGLMapViewCompass"];
diff --git a/platform/ios/uitest/MGLTelemetryTests.m b/platform/ios/uitest/MGLTelemetryTests.m
index fcee8bbdee..7a4d6db71c 100644
--- a/platform/ios/uitest/MGLTelemetryTests.m
+++ b/platform/ios/uitest/MGLTelemetryTests.m
@@ -1,26 +1,11 @@
-#import "MGLUITests.h"
+#import "MGLUITestCase.h"
-@interface MGLTelemetryTests : XCTestCase
+@interface MGLTelemetryTests : MGLUITestCase
@end
@implementation MGLTelemetryTests
-- (void)setUp {
- [super setUp];
-
- self.continueAfterFailure = NO;
- [XCUIDevice sharedDevice].orientation = UIDeviceOrientationPortrait;
- XCUIApplication *app = [[XCUIApplication alloc] init];
-
- // Bypass the access token prompt.
- NSMutableDictionary <NSString *, NSString *> *environment = app.launchEnvironment.mutableCopy;
- environment[@"MAPBOX_ACCESS_TOKEN"] = MGLUITestsBogusAccessToken;
- app.launchEnvironment = environment;
-
- [app launch];
-}
-
- (void)testOptOut {
XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *mapElement = app.otherElements[@"MGLMapView"];
diff --git a/platform/ios/uitest/MGLUITestCase.h b/platform/ios/uitest/MGLUITestCase.h
new file mode 100644
index 0000000000..84eba5d2a9
--- /dev/null
+++ b/platform/ios/uitest/MGLUITestCase.h
@@ -0,0 +1,5 @@
+#import <XCTest/XCTest.h>
+
+@interface MGLUITestCase : XCTestCase
+
+@end
diff --git a/platform/ios/uitest/MGLUITestCase.m b/platform/ios/uitest/MGLUITestCase.m
new file mode 100644
index 0000000000..e6d051e94c
--- /dev/null
+++ b/platform/ios/uitest/MGLUITestCase.m
@@ -0,0 +1,23 @@
+#import "MGLUITestCase.h"
+
+static NSString * const MGLUITestsBogusAccessToken = @"sk.feedCafeDeadBeef.BadeBede";
+
+@implementation MGLUITestCase
+
+- (void)setUp {
+ [super setUp];
+
+ self.continueAfterFailure = NO;
+ [XCUIDevice sharedDevice].orientation = UIDeviceOrientationPortrait;
+
+ // Launch the application, bypassing the access token prompt.
+ XCUIApplication *app = [[XCUIApplication alloc] init];
+ NSMutableDictionary <NSString *, NSString *> *environment = app.launchEnvironment.mutableCopy;
+ environment[@"MAPBOX_ACCESS_TOKEN"] = MGLUITestsBogusAccessToken;
+ environment[@"MAPBOX_DISABLE_ANIMATIONS"] = @"1";
+ environment[@"MAPBOX_CLEAN_START"] = @"1";
+ app.launchEnvironment = environment;
+ [app launch];
+}
+
+@end
diff --git a/platform/ios/uitest/MGLUITests.h b/platform/ios/uitest/MGLUITests.h
deleted file mode 100644
index 181b535688..0000000000
--- a/platform/ios/uitest/MGLUITests.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#import <XCTest/XCTest.h>
-
-static NSString * const MGLUITestsBogusAccessToken = @"sk.feedCafeDeadBeef.BadeBede";