- 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.
36 lines
1.1 KiB
Objective-C
36 lines
1.1 KiB
Objective-C
//
|
|
// Based on gist by Eric Allam
|
|
// https://gist.github.com/ericallam/5689235
|
|
//
|
|
|
|
#import "LocationMocker.h"
|
|
#import "CSSwizzler.h"
|
|
#import "CLLocationManager+MockLocation.h"
|
|
|
|
@implementation LocationMocker
|
|
|
|
+ (void)load
|
|
{
|
|
[CSSwizzler swizzleClass:[CLLocationManager class]
|
|
replaceMethod:@selector(startUpdatingLocation)
|
|
withMethod:@selector(custom_startUpdatingLocation)];
|
|
|
|
[CSSwizzler swizzleClass:[CLLocationManager class]
|
|
replaceMethod:@selector(location)
|
|
withMethod:@selector(custom_location)];
|
|
|
|
[CSSwizzler swizzleClass:[CLLocationManager class]
|
|
replaceMethod:@selector(startUpdatingHeading)
|
|
withMethod:@selector(custom_startUpdatingHeading)];
|
|
|
|
[CSSwizzler swizzleClass:[CLLocationManager class]
|
|
replaceMethod:@selector(heading)
|
|
withMethod:@selector(custom_heading)];
|
|
|
|
[CSSwizzler swizzleClass:[CLLocationManager class]
|
|
replaceClassMethod:@selector(headingAvailable)
|
|
withMethod:@selector(custom_headingAvailable)];
|
|
}
|
|
|
|
@end
|