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

Add location tests for iOS #1630

Closed
wants to merge 1 commit into from
Closed

Add location tests for iOS #1630

wants to merge 1 commit into from

Conversation

friedbunny
Copy link
Contributor

Fakes user location via swizzled CLLocationManager and hard-coded mock coordinates and heading.

I've had this sitting around for a bit and finally cleaned it up for a pull request. This uses manual swizzling and predates our use of OCMock, but I plan to look into whether or not this would be better if switched.

One thing to note: The test app no longer pops-up the location permission alert because the mock CLLocationManager does an end-run around permissions. This saves time before every test (by not calling [tester acknowledgeSystemAlert]), but does diverge significantly from the norm and isn't ideal.

I plan to add tests for location permissions handling, so I'll have to confront this problem soon.

/cc @1ec5 @bleege @incanus

@friedbunny
Copy link
Contributor Author

2015-05-22 19:35:25.041 Mapbox GL Tests[56917:4356076] KIFTester loaded
Test Suite 'Selected tests' started at 2015-05-23 02:35:26 +0000
Test Suite 'Test Bundle.xctest' started at 2015-05-23 02:35:26 +0000
Test Suite 'MapViewTests' started at 2015-05-23 02:35:26 +0000
Test Case '-[MapViewTests testBottomLayoutGuide]' started.
Test Case '-[MapViewTests testBottomLayoutGuide]' passed (0.014 seconds).
Test Case '-[MapViewTests testCenterSet]' started.
Test Case '-[MapViewTests testCenterSet]' passed (1.267 seconds).
Test Case '-[MapViewTests testCompassTap]' started.
Test Case '-[MapViewTests testCompassTap]' passed (1.657 seconds).
Test Case '-[MapViewTests testDelegateRegionDidChange]' started.
Test Case '-[MapViewTests testDelegateRegionDidChange]' passed (3.381 seconds).
Test Case '-[MapViewTests testDelegatesStartStopLocatingUser]' started.
Test Case '-[MapViewTests testDelegatesStartStopLocatingUser]' passed (0.003 seconds).
Test Case '-[MapViewTests testDirectionReset]' started.
Test Case '-[MapViewTests testDirectionReset]' passed (1.077 seconds).
Test Case '-[MapViewTests testDirectionSet]' started.
Test Case '-[MapViewTests testDirectionSet]' passed (1.059 seconds).
Test Case '-[MapViewTests testInsetMapView]' started.
Test Case '-[MapViewTests testInsetMapView]' passed (0.602 seconds).
Test Case '-[MapViewTests testPan]' started.
Test Case '-[MapViewTests testPan]' passed (1.062 seconds).
Test Case '-[MapViewTests testPanDisabled]' started.
Test Case '-[MapViewTests testPanDisabled]' passed (0.357 seconds).
Test Case '-[MapViewTests testRotate]' started.
Test Case '-[MapViewTests testRotate]' passed (2.256 seconds).
Test Case '-[MapViewTests testRotateDisabled]' started.
Test Case '-[MapViewTests testRotateDisabled]' passed (0.455 seconds).
Test Case '-[MapViewTests testTopLayoutGuide]' started.
Test Case '-[MapViewTests testTopLayoutGuide]' passed (0.735 seconds).
Test Case '-[MapViewTests testUserTrackingModeFollow]' started.
Test Case '-[MapViewTests testUserTrackingModeFollow]' passed (2.746 seconds).
Test Case '-[MapViewTests testZoom]' started.
Test Case '-[MapViewTests testZoom]' passed (1.648 seconds).
Test Case '-[MapViewTests testZoomDisabled]' started.
Test Case '-[MapViewTests testZoomDisabled]' passed (0.569 seconds).
Test Case '-[MapViewTests testZoomSet]' started.
Test Case '-[MapViewTests testZoomSet]' passed (0.003 seconds).
Test Suite 'MapViewTests' passed at 2015-05-23 02:35:45 +0000.
     Executed 17 tests, with 0 failures (0 unexpected) in 18.890 (18.897) seconds
Test Suite 'Test Bundle.xctest' passed at 2015-05-23 02:35:45 +0000.
     Executed 17 tests, with 0 failures (0 unexpected) in 18.890 (18.897) seconds
Test Suite 'Selected tests' passed at 2015-05-23 02:35:45 +0000.
     Executed 17 tests, with 0 failures (0 unexpected) in 18.890 (18.898) seconds

@incanus incanus added iOS Mapbox Maps SDK for iOS tests labels May 23, 2015
@bleege bleege added this to the iOS Beta 2 milestone May 29, 2015
@@ -13,7 +22,7 @@ @interface MapViewTests : KIFTestCase <MGLMapViewDelegate>
@implementation MapViewTests

- (void)beforeEach {
[tester acknowledgeSystemAlert];
//[tester acknowledgeSystemAlert];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed now. (Yay!)

@1ec5
Copy link
Contributor

1ec5 commented Jun 1, 2015

👍

@1ec5
Copy link
Contributor

1ec5 commented Jun 15, 2015

@friedbunny, can you rebase and integrate this change? Thanks!

@friedbunny
Copy link
Contributor Author

Yes, I'll hit this today. I'm a little nervous about Travis throwing a tantrum, but we'll take that as it comes.

- Adds testDelegatesStartStopLocatingUser: Tests mapViewWillStartLocatingUser and mapViewDidStopLocatingUser delegate methods
- Adds testUserTrackingModeFollow
- Adds testUserTrackingModeFollowWithHeading (disabled because of library bug)

Fakes user location via swizzled CLLocationManager and hard-coded mock coordinates and heading.
@friedbunny friedbunny self-assigned this Jun 15, 2015
@friedbunny
Copy link
Contributor Author

Passed on Travis, merged in e75e538.

@friedbunny friedbunny closed this Jun 16, 2015
@friedbunny friedbunny deleted the ios-location-tests branch June 16, 2015 00:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants