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

Commit

Permalink
[ios] iosapp UI tests
Browse files Browse the repository at this point in the history
Added a UI test bundle that uses XCUITest to test iosapp. The bundle contains some basic tests of annotation functionality. Gather code coverage data in the iosapp and dynamic schemes.

Added accessibility identifiers for key controls in the SDK and iosapp.

Working towards #4794.
  • Loading branch information
1ec5 committed May 4, 2016
1 parent 9a280b8 commit 2c2b3c0
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 2 deletions.
4 changes: 4 additions & 0 deletions platform/ios/app/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<barButtonItem key="leftBarButtonItem" image="settings.png" id="Jw8-JP-CaZ" userLabel="Map Settings">
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityLabel" value="Map settings"/>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="MBXSettingsButton"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="showSettings:" destination="WaX-pd-UZQ" id="X2C-Ee-Qvt"/>
Expand Down Expand Up @@ -174,6 +175,9 @@
<navigationBar key="navigationBar" contentMode="scaleToFill" id="ONr-CS-J5X">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="MBXNavigationBar"/>
</userDefinedRuntimeAttributes>
</navigationBar>
<nil name="viewControllers"/>
<connections>
Expand Down
107 changes: 107 additions & 0 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
DA35A2CA1CCAAAD200E826B2 /* NSValue+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA35A2C71CCAAAD200E826B2 /* NSValue+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA35A2CB1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DA35A2C81CCAAAD200E826B2 /* NSValue+MGLAdditions.m */; };
DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DA35A2C81CCAAAD200E826B2 /* NSValue+MGLAdditions.m */; };
DA4A0DF01CCE82500045352A /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4A0DEF1CCE82500045352A /* MGLAnnotationTests.m */; };
DA821D061CCC6D59007508D4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DA821D041CCC6D59007508D4 /* LaunchScreen.storyboard */; };
DA821D071CCC6D59007508D4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DA821D051CCC6D59007508D4 /* Main.storyboard */; };
DA8847D91CBAF91600AB86E3 /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; };
Expand Down Expand Up @@ -253,6 +254,13 @@
remoteGlobalIDString = DA8847D11CBAF91600AB86E3;
remoteInfo = dynamic;
};
DA4A0DF21CCE82500045352A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DA1DC9421CB6C1C2006E619F /* Project object */;
proxyType = 1;
remoteGlobalIDString = DA1DC9491CB6C1C2006E619F;
remoteInfo = iosapp;
};
DA8847D71CBAF91600AB86E3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DA1DC9421CB6C1C2006E619F /* Project object */;
Expand Down Expand Up @@ -344,6 +352,9 @@
DA35A2C71CCAAAD200E826B2 /* NSValue+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLAdditions.h"; sourceTree = "<group>"; };
DA35A2C81CCAAAD200E826B2 /* NSValue+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSValue+MGLAdditions.m"; sourceTree = "<group>"; };
DA35A2D11CCAB25200E826B2 /* jazzy.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = jazzy.yml; sourceTree = "<group>"; };
DA4A0DED1CCE82500045352A /* uitest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = uitest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA4A0DEF1CCE82500045352A /* MGLAnnotationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationTests.m; sourceTree = "<group>"; };
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; };
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>"; };
Expand Down Expand Up @@ -481,6 +492,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4A0DEA1CCE82500045352A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA8847CE1CBAF91600AB86E3 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -518,6 +536,7 @@
DABCABA91CB80692000A7C39 /* Benchmarking App */,
DA8847D31CBAF91600AB86E3 /* SDK */,
DA2E88521CC036F400F24E7B /* SDK Tests */,
DA4A0DEE1CCE82500045352A /* uitest */,
DA1DC9921CB6DF24006E619F /* Frameworks */,
DAC07C951CBB2CAD000CB309 /* Configuration */,
DA1DC94B1CB6C1C2006E619F /* Products */,
Expand All @@ -534,6 +553,7 @@
DA2E88511CC036F400F24E7B /* test.xctest */,
DA8933D51CCD306400E68420 /* Mapbox.bundle */,
DA25D5B91CCD9EDE00607828 /* Settings.bundle */,
DA4A0DED1CCE82500045352A /* uitest.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -612,6 +632,15 @@
path = test;
sourceTree = "<group>";
};
DA4A0DEE1CCE82500045352A /* uitest */ = {
isa = PBXGroup;
children = (
DA4A0DEF1CCE82500045352A /* MGLAnnotationTests.m */,
DA4A0DF11CCE82500045352A /* Info.plist */,
);
path = uitest;
sourceTree = "<group>";
};
DA8847D31CBAF91600AB86E3 /* SDK */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -983,6 +1012,24 @@
productReference = DA2E88511CC036F400F24E7B /* test.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
DA4A0DEC1CCE82500045352A /* uitest */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA4A0DF61CCE82500045352A /* Build configuration list for PBXNativeTarget "uitest" */;
buildPhases = (
DA4A0DE91CCE82500045352A /* Sources */,
DA4A0DEA1CCE82500045352A /* Frameworks */,
DA4A0DEB1CCE82500045352A /* Resources */,
);
buildRules = (
);
dependencies = (
DA4A0DF31CCE82500045352A /* PBXTargetDependency */,
);
name = uitest;
productName = uitest;
productReference = DA4A0DED1CCE82500045352A /* uitest.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
DA8847D11CBAF91600AB86E3 /* dynamic */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA8847DD1CBAF91600AB86E3 /* Build configuration list for PBXNativeTarget "dynamic" */;
Expand Down Expand Up @@ -1075,6 +1122,10 @@
DA2E88501CC036F400F24E7B = {
CreatedOnToolsVersion = 7.3;
};
DA4A0DEC1CCE82500045352A = {
CreatedOnToolsVersion = 7.3;
TestTargetID = DA1DC9491CB6C1C2006E619F;
};
DA8847D11CBAF91600AB86E3 = {
CreatedOnToolsVersion = 7.3;
};
Expand Down Expand Up @@ -1109,6 +1160,7 @@
DA8933D41CCD306400E68420 /* bundle */,
DA25D5B81CCD9EDE00607828 /* settings */,
DA2E88501CC036F400F24E7B /* test */,
DA4A0DEC1CCE82500045352A /* uitest */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -1145,6 +1197,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4A0DEB1CCE82500045352A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DA8847D01CBAF91600AB86E3 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1235,6 +1294,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DA4A0DE91CCE82500045352A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA4A0DF01CCE82500045352A /* MGLAnnotationTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DA8847CD1CBAF91600AB86E3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1343,6 +1410,11 @@
target = DA8847D11CBAF91600AB86E3 /* dynamic */;
targetProxy = DA2E88571CC036F400F24E7B /* PBXContainerItemProxy */;
};
DA4A0DF31CCE82500045352A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DA1DC9491CB6C1C2006E619F /* iosapp */;
targetProxy = DA4A0DF21CCE82500045352A /* PBXContainerItemProxy */;
};
DA8847D81CBAF91600AB86E3 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DA8847D11CBAF91600AB86E3 /* dynamic */;
Expand Down Expand Up @@ -1567,6 +1639,32 @@
};
name = Release;
};
DA4A0DF41CCE82500045352A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
INFOPLIST_FILE = uitest/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.uitest;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_TARGET_NAME = iosapp;
};
name = Debug;
};
DA4A0DF51CCE82500045352A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
INFOPLIST_FILE = uitest/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.uitest;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_TARGET_NAME = iosapp;
};
name = Release;
};
DA8847DB1CBAF91600AB86E3 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = DAC07C961CBB2CD6000CB309 /* mbgl.xcconfig */;
Expand Down Expand Up @@ -1792,6 +1890,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA4A0DF61CCE82500045352A /* Build configuration list for PBXNativeTarget "uitest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DA4A0DF41CCE82500045352A /* Debug */,
DA4A0DF51CCE82500045352A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA8847DD1CBAF91600AB86E3 /* Build configuration list for PBXNativeTarget "dynamic" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
10 changes: 10 additions & 0 deletions platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA4A0DEC1CCE82500045352A"
BuildableName = "uitest.xctest"
BlueprintName = "uitest"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA4A0DEC1CCE82500045352A"
BuildableName = "uitest.xctest"
BlueprintName = "uitest"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
10 changes: 10 additions & 0 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ - (instancetype)initWithAccessibilityContainer:(id)container tag:(MGLAnnotationT
return self;
}

- (NSString *)accessibilityIdentifier
{
return [NSString stringWithFormat:@"MGLMapViewAnnotation %d", self.tag];
}

- (void)accessibilityIncrement
{
[self.accessibilityContainer accessibilityIncrement];
Expand Down Expand Up @@ -182,6 +187,7 @@ - (instancetype)initWithAccessibilityContainer:(id)container
if (self = [super initWithAccessibilityContainer:container])
{
self.accessibilityTraits = UIAccessibilityTraitButton;
self.accessibilityIdentifier = NSStringFromClass([self class]);
self.accessibilityLabel = [self.accessibilityContainer accessibilityLabel];
self.accessibilityHint = @"Returns to the map";
}
Expand Down Expand Up @@ -362,6 +368,7 @@ - (void)commonInit
// setup accessibility
//
// self.isAccessibilityElement = YES;
self.accessibilityIdentifier = NSStringFromClass([self class]);
self.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"MAP_A11Y_LABEL", nil, nil, @"Map", @"Accessibility label");
self.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitAdjustable;
_accessibilityCompassFormatter = [[MGLCompassDirectionFormatter alloc] init];
Expand Down Expand Up @@ -411,6 +418,7 @@ - (void)commonInit
//
UIImage *logo = [[MGLMapView resourceImageNamed:@"mapbox.png"] imageWithAlignmentRectInsets:UIEdgeInsetsMake(1.5, 4, 3.5, 2)];
_logoView = [[UIImageView alloc] initWithImage:logo];
_logoView.accessibilityIdentifier = @"MGLMapViewLogo";
_logoView.accessibilityTraits = UIAccessibilityTraitStaticText;
_logoView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"LOGO_A11Y_LABEL", nil, nil, @"Mapbox", @"Accessibility label");
_logoView.translatesAutoresizingMaskIntoConstraints = NO;
Expand All @@ -420,6 +428,7 @@ - (void)commonInit
// setup attribution
//
_attributionButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
_attributionButton.accessibilityIdentifier = @"MGLMapViewInfo";
_attributionButton.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"INFO_A11Y_LABEL", nil, nil, @"About this map", @"Accessibility label");
_attributionButton.accessibilityHint = NSLocalizedStringWithDefaultValue(@"INFO_A11Y_HINT", nil, nil, @"Shows credits, a feedback form, and more", @"Accessibility hint");
[_attributionButton addTarget:self action:@selector(showAttribution) forControlEvents:UIControlEventTouchUpInside];
Expand All @@ -436,6 +445,7 @@ - (void)commonInit
_compassView.userInteractionEnabled = YES;
[_compassView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleCompassTapGesture:)]];
_compassView.accessibilityTraits = UIAccessibilityTraitButton;
_compassView.accessibilityIdentifier = @"MGLMapViewCompass";
_compassView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_LABEL", nil, nil, @"Compass", @"Accessibility label");
_compassView.accessibilityHint = NSLocalizedStringWithDefaultValue(@"COMPASS_A11Y_HINT", nil, nil, @"Rotates the map to face due north", @"Accessibility hint");
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
Expand Down
5 changes: 5 additions & 0 deletions platform/ios/src/MGLUserLocationAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ - (BOOL)isAccessibilityElement
return !self.hidden;
}

- (NSString *)accessibilityIdentifier
{
return NSStringFromClass([self class]);
}

- (NSString *)accessibilityLabel
{
return self.annotation.title;
Expand Down
24 changes: 24 additions & 0 deletions platform/ios/uitest/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>en</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>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Loading

0 comments on commit 2c2b3c0

Please sign in to comment.