Skip to content

Commit

Permalink
Implement tap recenters map display, test passes now.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlisle committed Apr 25, 2013
1 parent eba84b1 commit d9dd8cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
12 changes: 8 additions & 4 deletions ApplicationTests/HMFViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>

// Uncomment the next two lines to use OCMockito for mock objects:
//#define MOCKITO_SHORTHAND
//#import <OCMockitoIOS/OCMockitoIOS.h>
#define MOCKITO_SHORTHAND
#import <OCMockitoIOS/OCMockitoIOS.h>

#import <MapKit/MKUserLocation.h>
#import <MapKit/MKTypes.h>
Expand Down Expand Up @@ -83,7 +82,12 @@ - (void)testThatTapRecentersMap

// Test that handleTap recenters the map
map.userTrackingMode = MKUserTrackingModeNone;
[self.testObj handleTap];

// UITapGestureRecognizer *mock = mockClass([UITapGestureRecognizer class]);
// UIGestureRecognizerState gestureState = UIGestureRecognizerStateEnded;
// [given([mock state]) willReturnInt:gestureState];

[self.testObj handleMapTap:nil];
MKUserTrackingMode mode = self.testObj.mapView.userTrackingMode;
STAssertEquals(mode,MKUserTrackingModeFollow,@"mode not MKUserTrackingModeFollow");

Expand Down
2 changes: 2 additions & 0 deletions HowsMyFuel/HMFViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
@property (nonatomic, strong) HMFPresenter* presenter;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;

- (void)handleMapTap:(UIGestureRecognizer *)sender;

@end
16 changes: 15 additions & 1 deletion HowsMyFuel/HMFViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "HMFViewController.h"

@interface HMFViewController ()

@end

@implementation HMFViewController
Expand All @@ -27,6 +26,7 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self configureMapSettings];
[self setupGestureRecognizers];
}

- (void)didReceiveMemoryWarning
Expand All @@ -40,4 +40,18 @@ - (void)configureMapSettings
[[self mapView]setUserTrackingMode:MKUserTrackingModeFollow];
}

- (void)setupGestureRecognizers
{
// Setup gesture recognizers
UITapGestureRecognizer *mapTapRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleMapTap:)];
[self.mapView addGestureRecognizer:mapTapRecognizer];
}

- (void)handleMapTap:(UIGestureRecognizer *)sender {
// if(sender.state == UIGestureRecognizerStateEnded){
// NSLog(@"Tap");
[[self mapView]setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
// }
}

@end

0 comments on commit d9dd8cd

Please sign in to comment.