summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-27 15:19:22 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-05-05 01:07:29 -0700
commit5a8ab88217206cbb2757e6cbd68f051deb196735 (patch)
tree4800f8878c21e6e67cbf259a0291b09a50984f30
parentbab404aa4537a642229f6e40b30c730c6e27d6e8 (diff)
downloadqtlocation-mapboxgl-5a8ab88217206cbb2757e6cbd68f051deb196735.tar.gz
[ios] Test user location tracking
Added a test that cycles among the user tracking modes and tests for the presence and size of the user dot or user puck in each mode. Simulate a current location in San Francisco. Added more accessibility identifiers to iosapp.
-rw-r--r--platform/ios/app/Main.storyboard3
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj6
-rw-r--r--platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme6
-rw-r--r--platform/ios/uitest/MGLUserLocationTests.m56
4 files changed, 69 insertions, 2 deletions
diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard
index fb9b0c6d39..9d4bb88210 100644
--- a/platform/ios/app/Main.storyboard
+++ b/platform/ios/app/Main.storyboard
@@ -60,6 +60,8 @@
<barButtonItem image="TrackingLocationOffMask.png" id="CQ1-GP-M6x" userLabel="User Tracking Mode">
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityLabel" value="User tracking mode"/>
+ <userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="MBXUserTrackingModeButton"/>
+ <userDefinedRuntimeAttribute type="string" keyPath="accessibilityValue" value="Off"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="locateUser:" destination="WaX-pd-UZQ" id="XgF-DB-z3f"/>
@@ -68,6 +70,7 @@
<barButtonItem systemItem="organize" id="5IK-vz-jKQ" userLabel="Offline Packs">
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityLabel" value="Offline packs"/>
+ <userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="MBXOfflinePacksButton"/>
</userDefinedRuntimeAttributes>
<connections>
<segue destination="7q0-lI-zqb" kind="show" identifier="ShowOfflinePacks" id="xjx-0t-0LD"/>
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index d93aa362e6..5468c68156 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -227,6 +227,7 @@
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 */; };
+ DAC49C641CD1678F009E1AA3 /* MGLUserLocationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DAC49C631CD1678F009E1AA3 /* MGLUserLocationTests.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -479,8 +480,9 @@
DABCABBF1CB80717000A7C39 /* locations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = locations.cpp; sourceTree = "<group>"; };
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>"; };
+ DAC49C621CD07D74009E1AA3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
+ DAC49C631CD1678F009E1AA3 /* MGLUserLocationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocationTests.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -649,6 +651,7 @@
DA4A0DEF1CCE82500045352A /* MGLAnnotationTests.m */,
DA6A65961CCF429800F21F6B /* MGLGestureTests.m */,
DA6A65B81CCF5DB900F21F6B /* MGLTelemetryTests.m */,
+ DAC49C631CD1678F009E1AA3 /* MGLUserLocationTests.m */,
DA4A0DF11CCE82500045352A /* Info.plist */,
);
name = "UI Tests";
@@ -1312,6 +1315,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ DAC49C641CD1678F009E1AA3 /* MGLUserLocationTests.m in Sources */,
DAC49C611CD03A96009E1AA3 /* MGLUITestCase.m in Sources */,
DA6A65971CCF429800F21F6B /* MGLGestureTests.m in Sources */,
DA6A65B91CCF5DB900F21F6B /* MGLTelemetryTests.m in Sources */,
diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
index ac2e4a93a7..ecb9f977c8 100644
--- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
+++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
- version = "1.3">
+ version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
@@ -48,6 +48,10 @@
BlueprintName = "uitest"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
+ <LocationScenarioReference
+ identifier = "San Francisco, CA, USA"
+ referenceType = "1">
+ </LocationScenarioReference>
</TestableReference>
</Testables>
<MacroExpansion>
diff --git a/platform/ios/uitest/MGLUserLocationTests.m b/platform/ios/uitest/MGLUserLocationTests.m
new file mode 100644
index 0000000000..e4c17f65cb
--- /dev/null
+++ b/platform/ios/uitest/MGLUserLocationTests.m
@@ -0,0 +1,56 @@
+#import "MGLUITestCase.h"
+
+@interface MGLUserLocationTests : MGLUITestCase
+
+@end
+
+@implementation MGLUserLocationTests
+
+- (void)testUserDot {
+ XCUIApplication *app = [[XCUIApplication alloc] init];
+ NSPredicate *exists = [NSPredicate predicateWithFormat:@"exists == YES"];
+ NSPredicate *isAbsent = [NSPredicate predicateWithFormat:@"exists == NO"];
+
+ XCUIElement *userLocationAnnotationElement = app.buttons[@"MGLUserLocationAnnotationView"];
+ XCTAssertFalse(userLocationAnnotationElement.exists, @"User dot should be hidden by default.");
+
+ XCUIElement *userTrackingModeElement = app.navigationBars[@"MBXNavigationBar"].buttons[@"MBXUserTrackingModeButton"];
+ XCTAssertEqualObjects(userTrackingModeElement.value, @"Off", @"User tracking mode should be off by default.");
+
+ // Change to user location tracking mode.
+ [self expectationForPredicate:exists evaluatedWithObject:userLocationAnnotationElement handler:nil];
+ [userTrackingModeElement tap];
+ XCTAssertEqualObjects(userTrackingModeElement.value, @"Follow location", @"User location tracking mode should be on after tapping the user tracking mode button.");
+ [self waitForExpectationsWithTimeout:3 handler:nil];
+ CGRect userDotAnnotationFrame = userLocationAnnotationElement.frame;
+
+ // Open the user dot’s callout view.
+ XCUIElement *titleText = app.staticTexts[@"You Are Here"];
+ [self expectationForPredicate:exists evaluatedWithObject:titleText handler:nil];
+ [userLocationAnnotationElement tap];
+ [self waitForExpectationsWithTimeout:1 handler:nil];
+
+ // Close the user dot’s callout view by tapping on the map proxy element. Note that the map proxy element has a gaping hole in the middle to accommodate the callout view.
+ XCUIElement *mapProxyElement = app.buttons[@"MGLMapViewProxyAccessibilityElement"];
+ [self expectationForPredicate:isAbsent evaluatedWithObject:mapProxyElement handler:nil];
+ XCUICoordinate *coordinate = [[mapProxyElement coordinateWithNormalizedOffset:CGVectorMake(0, 0)] coordinateWithOffset:CGVectorMake(100, 100)];
+ [coordinate tap];
+ [self waitForExpectationsWithTimeout:2 handler:nil];
+
+ // Change to user heading tracking mode.
+ [userTrackingModeElement tap];
+ XCTAssertEqualObjects(userTrackingModeElement.value, @"Follow location and heading", @"User heading tracking mode should be on after tapping the user tracking mode button.");
+
+ // Change to user course tracking mode.
+ [userTrackingModeElement tap];
+ XCTAssertEqualObjects(userTrackingModeElement.value, @"Follow course", @"Course tracking mode should be on after tapping the user tracking mode button.");
+ CGRect userPuckAnnotationFrame = userLocationAnnotationElement.frame;
+ XCTAssertGreaterThan(userPuckAnnotationFrame.size.width, userDotAnnotationFrame.size.width, @"User puck should be wider than a user dot.");
+ XCTAssertGreaterThan(userPuckAnnotationFrame.size.height, userDotAnnotationFrame.size.height, @"User puck should be taller than a user dot.");
+
+ // Turn user tracking mode off.
+ [userTrackingModeElement tap];
+ XCTAssertEqualObjects(userTrackingModeElement.value, @"Off", @"Course tracking mode should be off after tapping the user tracking mode button.");
+}
+
+@end