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

Commit

Permalink
re-remove external mocker
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Oct 23, 2015
1 parent 727c699 commit 2eac606
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 278 deletions.
39 changes: 0 additions & 39 deletions test/ios/LocationMocker/CLLocationManager+MockLocation.h

This file was deleted.

82 changes: 0 additions & 82 deletions test/ios/LocationMocker/CLLocationManager+MockLocation.m

This file was deleted.

22 changes: 0 additions & 22 deletions test/ios/LocationMocker/CSSwizzler.h

This file was deleted.

44 changes: 0 additions & 44 deletions test/ios/LocationMocker/CSSwizzler.m

This file was deleted.

25 changes: 0 additions & 25 deletions test/ios/LocationMocker/LocationMocker.h

This file was deleted.

35 changes: 0 additions & 35 deletions test/ios/LocationMocker/LocationMocker.m

This file was deleted.

31 changes: 26 additions & 5 deletions test/ios/MapViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,33 @@
#import "Mapbox.h"
#import "MGLTViewController.h"

#import "LocationMocker/LocationMocker.h"
#import <CoreLocation/CoreLocation.h>
#import <KIF/UIAutomationHelper.h>

@interface MGLMapView (LocationManager)
// Mapbox San Francisco
static const CLLocationDegrees kMockedLatitude = 37.775716;
static const CLLocationDegrees kMockedLongitude = -122.413688;

@property (nonatomic) CLLocationManager *locationManager;
@interface MGLMapView (Extensions)

- (void)mockLocation:(CLLocation *)location;

@end

@implementation MGLMapView (Extensions)

- (void)mockLocation:(CLLocation *)newLocation {
SEL selector = @selector(locationManager:didUpdateLocations:);
NSMethodSignature *signature = [self methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
invocation.target = self;
invocation.selector = selector;
CLLocationManager *locationManager = [self valueForKeyPath:@"locationManager"];
NSArray<CLLocation *> *locations = @[ newLocation ];
[invocation setArgument:&locationManager atIndex:2];
[invocation setArgument:&locations atIndex:3];
[invocation invoke];
}

@end

Expand Down Expand Up @@ -591,7 +611,7 @@ - (void)testDelegatesStartStopLocatingUser {
XCTAssertEqualObjects(notification.name,
@"mapViewWillStartLocatingUser",
@"mapViewWillStartLocatingUser delegate should receive message");
XCTAssertNotNil(tester.mapView.locationManager,
XCTAssertNotNil([tester.mapView valueForKeyPath:@"locationManager"],
"map view location manager should not be nil");

notification = [system waitForNotificationName:@"mapViewDidStopLocatingUser"
Expand All @@ -606,7 +626,7 @@ - (void)testDelegatesStartStopLocatingUser {
XCTAssertEqual(tester.mapView.userTrackingMode,
MGLUserTrackingModeNone,
@"user tracking mode should be none");
XCTAssertNil(tester.mapView.locationManager,
XCTAssertNil([tester.mapView valueForKeyPath:@"locationManager"],
"map view location manager should be nil");
}

Expand All @@ -620,6 +640,7 @@ - (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView {

- (void)testUserTrackingModeFollow {
tester.mapView.userTrackingMode = MGLUserTrackingModeFollow;
[tester.mapView mockLocation:[[CLLocation alloc] initWithLatitude:kMockedLatitude longitude:kMockedLongitude]];
[self approveLocationIfNeeded];
[tester waitForTimeInterval:2];

Expand Down
26 changes: 0 additions & 26 deletions test/ios/ios-tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
/* Begin PBXBuildFile section */
96567A231B0E84CD00D78776 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96567A221B0E84CD00D78776 /* LaunchScreen.xib */; };
96567A311B0E8BB900D78776 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96567A301B0E8BB900D78776 /* Images.xcassets */; };
96992E581B0FBB6F008978C0 /* CSSwizzler.m in Sources */ = {isa = PBXBuildFile; fileRef = 96992E541B0FBB6F008978C0 /* CSSwizzler.m */; };
96992E591B0FBB6F008978C0 /* LocationMocker.m in Sources */ = {isa = PBXBuildFile; fileRef = 96992E561B0FBB6F008978C0 /* LocationMocker.m */; };
96992E621B0FBC4F008978C0 /* CLLocationManager+MockLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 96992E611B0FBC4F008978C0 /* CLLocationManager+MockLocation.m */; };
DD043363196DBBD500E6F39D /* MGLTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DD04335F196DBBD500E6F39D /* MGLTAppDelegate.m */; };
DD043364196DBBD500E6F39D /* MGLTViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD043360196DBBD500E6F39D /* MGLTViewController.m */; };
DD043366196DBBE000E6F39D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DD043365196DBBE000E6F39D /* main.m */; };
Expand Down Expand Up @@ -80,12 +77,6 @@
/* Begin PBXFileReference section */
96567A221B0E84CD00D78776 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = SOURCE_ROOT; };
96567A301B0E8BB900D78776 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = SOURCE_ROOT; };
96992E531B0FBB6F008978C0 /* CSSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSwizzler.h; sourceTree = "<group>"; };
96992E541B0FBB6F008978C0 /* CSSwizzler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSwizzler.m; sourceTree = "<group>"; };
96992E551B0FBB6F008978C0 /* LocationMocker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationMocker.h; sourceTree = "<group>"; };
96992E561B0FBB6F008978C0 /* LocationMocker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationMocker.m; sourceTree = "<group>"; };
96992E601B0FBC4F008978C0 /* CLLocationManager+MockLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CLLocationManager+MockLocation.h"; sourceTree = "<group>"; };
96992E611B0FBC4F008978C0 /* CLLocationManager+MockLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CLLocationManager+MockLocation.m"; sourceTree = "<group>"; };
DACAD7111B08719F009119DC /* MGLMapboxEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MGLMapboxEvents.h; path = ../../platform/ios/MGLMapboxEvents.h; sourceTree = SOURCE_ROOT; };
DADD9EB51BD16D8B00DA9161 /* Compatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Compatibility.h; path = OHHTTPStubs/OHHTTPStubs/Sources/Compatibility.h; sourceTree = SOURCE_ROOT; };
DD043323196DB9BC00E6F39D /* Mapbox GL Tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mapbox GL Tests.app"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -168,19 +159,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
96992E501B0FBB6F008978C0 /* LocationMocker */ = {
isa = PBXGroup;
children = (
96992E601B0FBC4F008978C0 /* CLLocationManager+MockLocation.h */,
96992E611B0FBC4F008978C0 /* CLLocationManager+MockLocation.m */,
96992E531B0FBB6F008978C0 /* CSSwizzler.h */,
96992E541B0FBB6F008978C0 /* CSSwizzler.m */,
96992E551B0FBB6F008978C0 /* LocationMocker.h */,
96992E561B0FBB6F008978C0 /* LocationMocker.m */,
);
path = LocationMocker;
sourceTree = SOURCE_ROOT;
};
DD04331A196DB9BC00E6F39D = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -308,7 +286,6 @@
DD0E6F661B01806600DC035A /* MetricsTests.m */,
DDBD0167196DC46B0033959E /* Supporting Files */,
DDBD014D196DC3B00033959E /* KIF */,
96992E501B0FBB6F008978C0 /* LocationMocker */,
DD0E6F6B1B01906600DC035A /* OCMock */,
DD0E6F861B01B67100DC035A /* OHHTTPStubs */,
);
Expand Down Expand Up @@ -478,12 +455,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
96992E581B0FBB6F008978C0 /* CSSwizzler.m in Sources */,
96992E591B0FBB6F008978C0 /* LocationMocker.m in Sources */,
DD043366196DBBE000E6F39D /* main.m in Sources */,
DD043363196DBBD500E6F39D /* MGLTAppDelegate.m in Sources */,
DD043364196DBBD500E6F39D /* MGLTViewController.m in Sources */,
96992E621B0FBC4F008978C0 /* CLLocationManager+MockLocation.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 2eac606

Please sign in to comment.