Permalink
Browse files

Implement tap recenters map display, test passes now.

  • Loading branch information...
rlisle committed Apr 25, 2013
1 parent eba84b1 commit d9dd8cd30ea37222236aa194178362ad816ecf79
Showing with 25 additions and 5 deletions.
  1. +8 −4 ApplicationTests/HMFViewControllerTests.m
  2. +2 −0 HowsMyFuel/HMFViewController.h
  3. +15 −1 HowsMyFuel/HMFViewController.m
@@ -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>
@@ -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");
@@ -18,4 +18,6 @@
@property (nonatomic, strong) HMFPresenter* presenter;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
- (void)handleMapTap:(UIGestureRecognizer *)sender;
@end
@@ -9,7 +9,6 @@
#import "HMFViewController.h"
@interface HMFViewController ()
@end
@implementation HMFViewController
@@ -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
@@ -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.