Skip to content

Commit

Permalink
Use HEAD from EXPMatchers+FBSnapshotTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Mar 18, 2014
1 parent 98860e6 commit e8f9b78
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 69 deletions.
8 changes: 4 additions & 4 deletions Demo/Demo/NAInteractiveDemoViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@property (nonatomic, weak) IBOutlet NAMapView *mapView;

- (IBAction)addPin:(id)sender;
- (void)addPinAt:(CGPoint)point withColor:(NAPinColor)color;

- (IBAction)removePin:(id)sender;

- (IBAction)selectRandom:(id)sender;
- (void)selectPinAt:(NSInteger)index;

- (void)addPinAt:(CGPoint)point withColor:(NAPinColor)color animated:(BOOL)animated;
- (void)selectPinAt:(NSInteger)index animated:(BOOL)animated;
- (void)removePinAt:(NSInteger)index animated:(BOOL)animated;

@end
36 changes: 21 additions & 15 deletions Demo/Demo/NAInteractiveDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,45 @@ - (void)viewDidLoad
self.size = image.size;
}

- (IBAction)addPin:(id)sender{
- (IBAction)addPin:(id)sender {

NSInteger x = (arc4random() % (int)self.size.width);
NSInteger y = (arc4random() % (int)self.size.width);

CGPoint point = CGPointMake(x, y);

[self addPinAt:point withColor:arc4random() % 3];
[self addPinAt:point withColor:arc4random() % 3 animated:YES];
}

- (void)addPinAt:(CGPoint)point withColor:(NAPinColor)color{
- (void)addPinAt:(CGPoint)point withColor:(NAPinColor)color animated:(BOOL)animated {

[self.mapView centerOnPoint:point animated:YES];
[self.mapView centerOnPoint:point animated:animated];

NAPinAnnotation *annotation = [NAPinAnnotation annotationWithPoint:point];
annotation.title = [NSString stringWithFormat:@"Pin %@", @(self.annotations.count + 1)];
annotation.color = color;

[self.mapView addAnnotation:annotation animated:YES];
[self.mapView addAnnotation:annotation animated:animated];
[self.annotations addObject:annotation];

_lastFocused = annotation;
}

- (IBAction)removePin:(id)sender{
- (IBAction)removePin:(id)sender {
if(self.annotations.count <= 0 || self.lastFocused == nil) return;
[self.mapView centerOnPoint:self.lastFocused.point animated:YES];
[self.mapView removeAnnotation:self.lastFocused];
[self.annotations removeObject:self.lastFocused];
NSInteger index = [self.annotations indexOfObject:self.lastFocused];
[self removePinAt:index animated:YES];
self.lastFocused = self.annotations.lastObject;
}

- (IBAction)selectRandom:(id)sender{
- (void)removePinAt:(NSInteger)index animated:(BOOL)animated {
NAPinAnnotation *annotation = [self.annotations objectAtIndex:index];
[self.mapView centerOnPoint:annotation.point animated:animated];
[self.mapView removeAnnotation:annotation];
[self.annotations removeObject:annotation];
}

- (IBAction)selectRandom:(id)sender {
if(self.annotations.count <= 0) return;

NSInteger rand = (arc4random() % (int)self.annotations.count);
Expand All @@ -81,18 +87,18 @@ - (IBAction)selectRandom:(id)sender{
annotation = [self.annotations objectAtIndex:rand];
}

[self selectPin:annotation];
[self selectPin:annotation animated:YES];
}

- (void)selectPinAt:(NSInteger)index
- (void)selectPinAt:(NSInteger)index animated:(BOOL)animated
{
[self selectPin:[self.annotations objectAtIndex:index]];
[self selectPin:[self.annotations objectAtIndex:index] animated:animated];
}

- (void)selectPin:(NAPinAnnotation *)annotation
- (void)selectPin:(NAPinAnnotation *)annotation animated:(BOOL)animated
{
self.selectedPinLabel.text = [NSString stringWithFormat:@"%@", annotation.title];
[self.mapView selectAnnotation:annotation animated:YES];
[self.mapView selectAnnotation:annotation animated:animated];
_lastFocused = annotation;
}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NAPinAnnotationsDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (void)viewDidLoad
perth.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
perth.color = NAPinColorRed;

[mapView addAnnotation:perth animated:YES];
[mapView addAnnotation:perth animated:NO];

NAPinAnnotation * brisbane = [NAPinAnnotation annotationWithPoint:CGPointMake(679.0f, 302.0f)];
brisbane.title = @"Brisbane";
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/NATiledImageDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)viewDidLoad
mapView.backgroundColor = [UIColor colorWithRed:0.000f green:0.475f blue:0.761f alpha:1.000f];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
mapView.displayTileBorders = YES;
mapView.backgroundImage = [UIImage imageNamed:@"Maps/Armory2014/large.jpg"];
// mapView.backgroundImage = [UIImage imageNamed:@"Maps/Armory2014/large.jpg"];
mapView.zoomStep = 3.0f;
_mapView = mapView;

Expand Down
6 changes: 1 addition & 5 deletions Demo/DemoTests/NAAnnotationDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@

SpecBegin(NAAnnotationDemoViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

it(@"displays map with a pin", ^{
NADotAnnotationDemoViewController *vc = [[NADotAnnotationDemoViewController alloc] init];
expect(vc.view).willNot.beNil();
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
});

SpecEnd
27 changes: 11 additions & 16 deletions Demo/DemoTests/NAInteractiveDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

SpecBegin(NAInteractiveDemoViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

__block NAInteractiveDemoViewController *vc = nil;

beforeEach(^{
Expand All @@ -22,27 +18,26 @@
});

it(@"doesn't display any pins", ^{
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
});

it(@"adds a pin", ^{
[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed];
expect(vc.view).to.haveValidSnapshotNamed(@"add");

[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed animated:NO];
expect(vc.view).will.haveValidSnapshotNamed(@"add");
});

it(@"removes a pin", ^{
[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed];
[vc addPinAt:CGPointMake(200, 300) withColor:NAPinColorGreen];
[vc removePin:nil];
expect(vc.view).to.haveValidSnapshotNamed(@"remove");
[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed animated:NO];
[vc addPinAt:CGPointMake(200, 300) withColor:NAPinColorGreen animated:NO];
[vc removePinAt:0 animated:NO];
expect(vc.view).will.haveValidSnapshotNamed(@"remove");
});

it(@"selects a pin", ^{
[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed];
[vc addPinAt:CGPointMake(200, 300) withColor:NAPinColorGreen];
[vc selectPinAt:1];
expect(vc.view).to.haveValidSnapshotNamed(@"select");
[vc addPinAt:CGPointMake(100, 200) withColor:NAPinColorRed animated:NO];
[vc addPinAt:CGPointMake(200, 300) withColor:NAPinColorGreen animated:NO];
[vc selectPinAt:1 animated:NO];
expect(vc.view).will.haveValidSnapshotNamed(@"select");
});

SpecEnd
6 changes: 1 addition & 5 deletions Demo/DemoTests/NALoadViaNIBDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@

SpecBegin(NALoadViaNIBDemoViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

it(@"displays a menu", ^{
NALoadViaNIBDemoViewController *vc = [[NALoadViaNIBDemoViewController alloc] init];
expect(vc.view).willNot.beNil();
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
});

SpecEnd
6 changes: 1 addition & 5 deletions Demo/DemoTests/NAMasterViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@

SpecBegin(NAMasterViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

it(@"displays the master menu", ^{
NAMasterViewController *vc = [[NAMasterViewController alloc] initWithNibName:@"NAMasterViewController" bundle:nil];
expect(vc.view).willNot.beNil();
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
});

SpecEnd
6 changes: 1 addition & 5 deletions Demo/DemoTests/NAPinAnnotationsDemoViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

SpecBegin(NAPinAnnotationsDemoViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

__block NAPinAnnotationsDemoViewController *vc = nil;

beforeEach(^{
Expand All @@ -23,7 +19,7 @@
});

it(@"displays map with a pin", ^{
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
});

SpecEnd
9 changes: 2 additions & 7 deletions Demo/DemoTests/NATiledImageMapViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

SpecBegin(NATiledImageDemoViewController)

beforeAll(^{
setGlobalReferenceImageDir(FB_REFERENCE_IMAGE_DIR);
});

__block NATiledImageDemoViewController *vc = nil;

beforeEach(^{
Expand All @@ -23,11 +19,10 @@
[window makeKeyAndVisible];
});

// TODO: drawRect isn't called when running in a test until the test has finished
it(@"displays map with a pin", ^AsyncBlock {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long) NULL), ^(void) {
dispatch_async(dispatch_get_main_queue(), ^{
[NSThread sleepForTimeInterval:3.0];
expect(vc.view).to.haveValidSnapshotNamed(@"default");
expect(vc.view).will.haveValidSnapshotNamed(@"default");
done();
});
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ target "DemoTests" do
pod 'Specta', '~> 0.2.1'
pod 'Expecta', '~> 0.2.3'
pod 'FBSnapshotTestCase', '~> 1.1'
pod 'EXPMatchers+FBSnapshotTest', '~> 1.0'
pod 'EXPMatchers+FBSnapshotTest', :head
end

8 changes: 4 additions & 4 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ PODS:
- ARTiledImageView (1.0.0):
- SDWebImage
- Expecta (0.2.4)
- EXPMatchers+FBSnapshotTest (1.0):
- EXPMatchers+FBSnapshotTest (HEAD based on 1.0):
- Expecta
- FBSnapshotTestCase
- FBSnapshotTestCase (1.1)
- NAMapKit (3.0):
- NAMapKit (3.0.1):
- ARTiledImageView
- SDWebImage
- SDWebImage (3.5.4):
Expand All @@ -16,7 +16,7 @@ PODS:

DEPENDENCIES:
- Expecta (~> 0.2.3)
- EXPMatchers+FBSnapshotTest (~> 1.0)
- EXPMatchers+FBSnapshotTest (HEAD)
- FBSnapshotTestCase (~> 1.1)
- NAMapKit (from `../namapkit.podspec`)
- Specta (~> 0.2.1)
Expand All @@ -30,7 +30,7 @@ SPEC CHECKSUMS:
Expecta: 5c147dedfea5fbcf773995f7e65020abcc936ce5
EXPMatchers+FBSnapshotTest: 1b9506577e494191565ff51ffd5b1e76339d727b
FBSnapshotTestCase: 188c80bfcb72e744eb0b99d45989d12687c40cf8
NAMapKit: 18fa975d148161fe055cfd0fa18e8639dee45684
NAMapKit: af339ad3c614351ad93cba8e65bceaa8fcce3f9a
SDWebImage: 1a62010700adbba823b621fc217906739dbf6aa5
Specta: 2d06220591110c6d9757d8be8ecf8e63aa40dc2a

Expand Down

0 comments on commit e8f9b78

Please sign in to comment.