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

Commit

Permalink
fixes #830, #880: bring back iOS tests; split OS X & iOS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Apr 3, 2015
1 parent 5f94ee5 commit 81f5a5d
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[submodule "test/ios/KIF"]
path = test/ios/KIF
url = https://github.com/mapbox/KIF.git
url = https://github.com/kif-framework/KIF.git

[submodule "platform/ios/vendor/SMCalloutView"]
path = platform/ios/vendor/SMCalloutView
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ matrix:
env: BUILDTYPE=Release JOBS=8
compiler: gcc
- os: osx
env: BUILDTYPE=Debug JOBS=8
env: BUILDTYPE=Debug JOBS=8 TEST_OS=osx
compiler: clang
- os: osx
env: BUILDTYPE=Release JOBS=8 TEST_OS=ios
compiler: clang

env:
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ styles/styles:
SMCalloutView:
git submodule update --init platform/ios/vendor/SMCalloutView

KIF:
git submodule update --init test/ios/KIF

#### Library builds ############################################################

.PRECIOUS: Makefile/mbgl
Expand Down Expand Up @@ -124,6 +127,10 @@ ios: Xcode/ios
isim: Xcode/ios
xcodebuild -sdk iphonesimulator ARCHS="x86_64 i386" -project ./build/ios/ios/app/mapboxgl-app.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS)

itest: Xcode/ios KIF
./scripts/package_ios.sh
./scripts/test_ios.sh

# Legacy name
iproj: ios-proj

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Target OS X: 10.9+

If you merely want to install the library for iOS and try it out as an Objective-C consumer:

0. Use [Homebrew](http://brew.sh/) to install Boost headers: `brew install boost`.
0. Use [Homebrew](http://brew.sh/) to install Boost headers & some utilities: `brew install boost xcpretty xctool`.
1. Run `./scripts/package_ios.sh`. The packaging script will produce the statically-linked `libMapboxGL.a`, `MapboxGL.bundle` for resources, and a `Headers` folder.
2. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that:
- `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting.
Expand All @@ -70,6 +70,8 @@ If you merely want to install the library for iOS and try it out as an Objective

If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app.

You can also run `make itest` to run the included tests.

Target devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus) and iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2).

Target iOS: 7.0 through 8.1
Expand Down
4 changes: 3 additions & 1 deletion scripts/package_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ export BUILDTYPE=${BUILDTYPE:-Release}
export HOST=ios
make Xcode/mbgl

step "Building iOS targets..."
step "Building iOS device targets..."
xcodebuild -sdk iphoneos${IOS_SDK_VERSION} \
ARCHS="arm64 armv7 armv7s" \
ONLY_ACTIVE_ARCH=NO \
-project ./build/ios/mbgl.xcodeproj \
-configuration ${BUILDTYPE} \
-target everything \
Expand All @@ -45,6 +46,7 @@ xcodebuild -sdk iphoneos${IOS_SDK_VERSION} \
step "Building iOS Simulator targets..."
xcodebuild -sdk iphonesimulator${IOS_SDK_VERSION} \
ARCHS="x86_64 i386" \
ONLY_ACTIVE_ARCH=NO \
-project ./build/ios/mbgl.xcodeproj \
-configuration ${BUILDTYPE} \
-target everything \
Expand Down
14 changes: 14 additions & 0 deletions scripts/test_ios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e
set -o pipefail
set -u

xctool test \
-project ./test/ios/ios-tests.xcodeproj \
-scheme 'Mapbox GL Tests' \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=7.1' \
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.1' \
-destination 'platform=iOS Simulator,name=iPad 2,OS=7.1' \
-destination 'platform=iOS Simulator,name=iPad 2,OS=8.1'
16 changes: 9 additions & 7 deletions scripts/travis_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ elif [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
mapbox_time_finish
fi

elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
elif [[ ${TRAVIS_OS_NAME} == "osx" && ${TEST_OS} == "osx" ]]; then
#
# build OS X
#
mapbox_time "build_osx_project" \
mapbox_time "build_osx" \
make xosx -j$JOBS

elif [[ ${TRAVIS_OS_NAME} == "osx" && ${TEST_OS} == "ios" ]]; then
#
# build iOS
# test iOS
#
mapbox_time "build_ios_project_device_release" \
make ios -j$JOBS
mapbox_time "build_ios_project_simulator_debug" \
make isim -j$JOBS
mapbox_time "checkout_kif" \
git submodule update --init test/ios/KIF

mapbox_time "run_ios_tests"
make itest
fi
2 changes: 1 addition & 1 deletion styles
Submodule styles updated 727 files
2 changes: 1 addition & 1 deletion test/ios/KIF
Submodule KIF updated 66 files
+4 −1 .travis.yml
+8 −2 Additions/UIAccessibilityElement-KIFAdditions.m
+1 −1 Additions/UIApplication-KIFAdditions.h
+18 −7 Additions/UIApplication-KIFAdditions.m
+19 −0 Additions/UIEvent+KIFAdditions.h
+152 −0 Additions/UIEvent+KIFAdditions.m
+34 −0 Additions/UIView-KIFAdditions.h
+333 −84 Additions/UIView-KIFAdditions.m
+52 −0 Additions/XCTestCase-KIFAdditions.m
+8 −0 Classes/KIFSystemTestActor.h
+23 −5 Classes/KIFSystemTestActor.m
+3 −0 Classes/KIFTestActor.h
+2 −0 Classes/KIFTestActor.m
+37 −28 Classes/KIFTestCase.m
+2 −0 Classes/KIFTypist.h
+43 −147 Classes/KIFTypist.m
+7 −7 Classes/KIFUITestActor-ConditionalTests.h
+58 −7 Classes/KIFUITestActor.h
+237 −65 Classes/KIFUITestActor.m
+17 −0 Classes/UIAutomationHelper.h
+84 −0 Classes/UIAutomationHelper.m
+556 −0 Documentation/Examples/Testable Swift/Testable Swift.xcodeproj/project.pbxproj
+96 −0 Documentation/Examples/Testable Swift/Testable Swift.xcodeproj/xcshareddata/xcschemes/Testable Swift.xcscheme
+15 −0 Documentation/Examples/Testable Swift/Testable Swift/AppDelegate.swift
+41 −0 Documentation/Examples/Testable Swift/Testable Swift/Base.lproj/LaunchScreen.xib
+102 −0 Documentation/Examples/Testable Swift/Testable Swift/Base.lproj/Main.storyboard
+38 −0 Documentation/Examples/Testable Swift/Testable Swift/Images.xcassets/AppIcon.appiconset/Contents.json
+50 −0 Documentation/Examples/Testable Swift/Testable Swift/Info.plist
+19 −0 Documentation/Examples/Testable Swift/Testable Swift/MasterViewController.swift
+24 −0 Documentation/Examples/Testable Swift/Testable SwiftTests/Info.plist
+24 −0 Documentation/Examples/Testable Swift/Testable SwiftTests/SimpleObjCTest.m
+29 −0 Documentation/Examples/Testable Swift/Testable SwiftTests/SimpleSwiftTest.swift
+5 −0 Documentation/Examples/Testable Swift/Testable SwiftTests/Testable SwiftTests-Bridging-Header.h
+37 −0 Documentation/Examples/Testable Swift/Testable SwiftTests/Testable_SwiftTests.swift
+ Documentation/Images/Add Category Linker Flags.png
+ Documentation/Images/Add Library Sheet.png
+ Documentation/Images/Add Library.png
+ Documentation/Images/Added KIF to Project.png
+ Documentation/Images/Simple App.png
+80 −0 IdentifierTests/KIFUITestActor-IdentifierTests.h
+206 −0 IdentifierTests/KIFUITestActor-IdentifierTests.m
+91 −0 KIF Tests/AccessibilityIdentifierTests.m
+1 −1 KIF Tests/CollectionViewTests.m
+1 −1 KIF Tests/LandscapeTests.m
+59 −0 KIF Tests/MultiFingerTests.m
+17 −3 KIF Tests/PickerTests.m
+16 −11 KIF Tests/SpecificControlTests.m
+43 −0 KIF Tests/SystemAlertTests.m
+5 −0 KIF Tests/SystemTests.m
+6 −1 KIF Tests/TableViewTests.m
+25 −2 KIF Tests/TypingTests.m
+31 −0 KIF Tests/WaitForAnimationTests.m
+43 −0 KIF Tests/WebViewTests.m
+10 −3 KIF.podspec
+107 −4 KIF.xcodeproj/project.pbxproj
+123 −78 README.md
+25 −0 Test Host/AnimationViewController.m
+1 −1 Test Host/PickerController.m
+42 −0 Test Host/SystemAlertViewController.m
+19 −1 Test Host/TapViewController.m
+2 −0 Test Host/Test Host-Info.plist
+9 −4 Test Host/TestSuiteViewController.m
+23 −0 Test Host/WebViewController.m
+224 −10 Test Host/en.lproj/MainStoryboard.storyboard
+14 −0 Test Host/index.html
+6 −0 Test Host/page2.html
1 change: 1 addition & 0 deletions test/ios/KIFTestActor+MapboxGL.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import <UIKit/UIKit.h>
#import <KIF/KIF.h>

@class MGLMapView;
Expand Down
5 changes: 3 additions & 2 deletions test/ios/KIFTestActor+MapboxGL.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#import "KIFTestActor+MapboxGL.h"

#import "MapboxGL.h"

#import <KIF/UIApplication-KIFAdditions.h>
#import <KIF/UIAccessibilityElement-KIFAdditions.h>
#import "MGLMapView.h"

@implementation KIFTestActor (MapboxGL)

Expand Down
2 changes: 1 addition & 1 deletion test/ios/MGLTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

@interface MGLTAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic) UIWindow *window;

@end
2 changes: 1 addition & 1 deletion test/ios/MGLTViewController.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "MGLTViewController.h"
#import "MGLMapView.h"
#import "MapboxGL.h"

@implementation MGLTViewController

Expand Down
86 changes: 64 additions & 22 deletions test/ios/MapViewTests.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#import "MapViewTests.h"
#import <KIF/KIFTestStepValidation.h>

#import "KIFTestActor+MapboxGL.h"
#import "MGLMapView.h"

#import "MapboxGL.h"

#import <KIF/KIFTestStepValidation.h>

@interface MapViewTests () <MGLMapViewDelegate>

Expand Down Expand Up @@ -91,17 +94,19 @@ - (void)testZoom {
distance:50
steps:10];

XCTAssertTrue(tester.mapView.zoomLevel > zoom,
@"zoom gesture should increase zoom level");
XCTAssertGreaterThan(tester.mapView.zoomLevel,
zoom,
@"zoom gesture should increase zoom level");

zoom = tester.mapView.zoomLevel;
[tester.mapView pinchAtPoint:CGPointMake(tester.mapView.bounds.size.width / 2,
tester.mapView.bounds.size.height / 2)
distance:50
steps:10];

XCTAssertTrue(tester.mapView.zoomLevel < zoom,
@"pinch gesture should decrease zoom level");
XCTAssertLessThan(tester.mapView.zoomLevel,
zoom,
@"pinch gesture should decrease zoom level");
}

- (void)testZoomDisabled {
Expand Down Expand Up @@ -132,10 +137,12 @@ - (void)testPan {

[tester.mapView dragFromPoint:CGPointMake(10, 10) toPoint:CGPointMake(300, 300) steps:10];

XCTAssertTrue(tester.mapView.centerCoordinate.latitude > centerCoordinate.latitude,
@"panning map down should increase center latitude");
XCTAssertTrue(tester.mapView.centerCoordinate.longitude < centerCoordinate.longitude,
@"panning map right should decrease center longitude");
XCTAssertGreaterThan(tester.mapView.centerCoordinate.latitude,
centerCoordinate.latitude,
@"panning map down should increase center latitude");
XCTAssertLessThan(tester.mapView.centerCoordinate.longitude,
centerCoordinate.longitude,
@"panning map right should decrease center longitude");
}

- (void)testPanDisabled {
Expand All @@ -144,12 +151,45 @@ - (void)testPanDisabled {

[tester.mapView dragFromPoint:CGPointMake(10, 10) toPoint:CGPointMake(300, 300) steps:10];

__KIFAssertEqual(centerCoordinate.latitude,
tester.mapView.centerCoordinate.latitude,
@"disabling pan gesture should disallow vertical panning");
__KIFAssertEqual(centerCoordinate.longitude,
tester.mapView.centerCoordinate.longitude,
@"disabling pan gesture should disallow horizontal panning");
XCTAssertEqualWithAccuracy(centerCoordinate.latitude,
tester.mapView.centerCoordinate.latitude,
0.005,
@"disabling pan gesture should disallow vertical panning");
XCTAssertEqualWithAccuracy(centerCoordinate.longitude,
tester.mapView.centerCoordinate.longitude,
0.005,
@"disabling pan gesture should disallow horizontal panning");
}

- (void)testRotate {
CLLocationDirection startAngle = tester.mapView.direction;

XCTAssertNotEqual(startAngle,
45,
@"start angle must not be destination angle");

[tester.mapView twoFingerRotateAtPoint:tester.mapView.center angle:45];

XCTAssertGreaterThanOrEqual(fabs(tester.mapView.direction - startAngle),
20,
@"rotating map should change angle");
}

- (void)testRotateDisabled {
tester.mapView.rotateEnabled = NO;

CLLocationDirection startAngle = tester.mapView.direction;

XCTAssertNotEqual(startAngle,
45,
@"start angle must not be destination angle");

[tester.mapView twoFingerRotateAtPoint:tester.mapView.center angle:45];

XCTAssertEqualWithAccuracy(tester.mapView.direction,
startAngle,
0.005,
@"disabling rotation show disallow rotation gestures");
}

- (void)testCenterSet {
Expand All @@ -161,12 +201,14 @@ - (void)testCenterSet {
newCenterCoordinate.longitude,
@"initial setup should have differing center longitude");

[tester.mapView setCenterCoordinate:newCenterCoordinate];
tester.mapView.centerCoordinate = newCenterCoordinate;

XCTAssertTrue(tester.mapView.centerCoordinate.latitude == newCenterCoordinate.latitude,
@"setting center should change latitude");
XCTAssertTrue(tester.mapView.centerCoordinate.longitude == newCenterCoordinate.longitude,
@"setting center should change longitude");
XCTAssertEqual(tester.mapView.centerCoordinate.latitude,
newCenterCoordinate.latitude,
@"setting center should change latitude");
XCTAssertEqual(tester.mapView.centerCoordinate.longitude,
newCenterCoordinate.longitude,
@"setting center should change longitude");
}

- (void)testZoomSet {
Expand Down Expand Up @@ -233,7 +275,7 @@ - (void)testBottomLayoutGuide {
logoBugFrame = [logoBug.superview convertRect:logoBug.frame toView:nil];
toolbarFrame = [tester.window convertRect:toolbar.frame toView:nil];
XCTAssertFalse(CGRectIntersectsRect(logoBugFrame, toolbarFrame),
@"rotated device should not have logo buy under toolbar");
@"rotated device should not have logo bug under toolbar");

attributionButtonFrame = [attributionButton.superview convertRect:attributionButton.frame toView:nil];
XCTAssertFalse(CGRectIntersectsRect(attributionButtonFrame, toolbarFrame),
Expand Down
9 changes: 0 additions & 9 deletions test/ios/README.md

This file was deleted.

Loading

0 comments on commit 81f5a5d

Please sign in to comment.