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 1, 2015
1 parent 3d9b441 commit d5b2825
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 154 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
6 changes: 5 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=Debug JOBS=8 TEST_OS=ios
compiler: clang

env:
Expand Down Expand Up @@ -65,6 +68,7 @@ before_install:
- ./scripts/travis_before_install.sh
- if [[ ${TRAVIS_OS_NAME} == "linux" && ${MASON_PLATFORM} != "android" ]]; then export LD_LIBRARY_PATH=`mason prefix mesa 10.4.3`/lib; fi
- if [[ ${TRAVIS_OS_NAME} == "linux" && ${MASON_PLATFORM} != "android" ]]; then glxinfo; fi
- if [[ ${TRAVIS_OS_NAME} == "osx" ]]; then gem install xcpretty --no-rdoc --no-ri --no-document --quiet; fi

install:
- ulimit -c
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
2 changes: 1 addition & 1 deletion scripts/package_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ 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" \
-project ./build/ios/mbgl.xcodeproj \
Expand Down
11 changes: 11 additions & 0 deletions scripts/test_ios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e
set -o pipefail
set -u

xcodebuild test \
-project ./test/ios/ios-tests.xcodeproj \
-scheme 'Mapbox GL Tests' \
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=latest' \
-destination-timeout 1
19 changes: 12 additions & 7 deletions scripts/travis_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,23 @@ 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 "build_ios_static" \
./scripts/package_ios.sh

mapbox_time "checkout_kif" \
git submodule update --init test/ios/KIF

mapbox_time "run_ios_tests" \
./scripts/test_ios.sh | xcpretty -c
fi
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
50 changes: 41 additions & 9 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 @@ -144,12 +147,41 @@ - (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;

XCTAssertFalse(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;

XCTAssertFalse(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 Down Expand Up @@ -233,7 +265,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 d5b2825

Please sign in to comment.