Skip to content

Commit

Permalink
Revert "#40 Added more to the collection fixture - I'm thinking that …
Browse files Browse the repository at this point in the history
…we can reduce a lot of the boilerplate in mocking and stubbing collection instances with this class"

This reverts commit ddc6a92.
  • Loading branch information
SteveFortune committed Dec 11, 2014
1 parent ddc6a92 commit f44691e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 54 deletions.
8 changes: 0 additions & 8 deletions Demo/Tests/I3CollectionFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,4 @@

@interface I3CollectionFixture : NSObject <I3Collection>

@property (nonatomic, readonly, copy) NSMutableDictionary *items;

-(id) initWithItemAtPoint:(CGPoint) at;

-(void) setValidPointInsideCollection:(CGPoint) point;

-(void) setValidIndexPath:(NSIndexPath *)index;

@end
52 changes: 7 additions & 45 deletions Demo/Tests/I3CollectionFixture.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,20 @@
#import "I3CollectionFixture.h"


@interface I3CollectionFixture () {

UIView *_collectionView;
}

@end

@implementation I3CollectionFixture

-(id) init{

self = [super init];

if(self){
_collectionView = OCMPartialMock([[UIView alloc] init]);
}

return self;
}

-(id) initWithItemAtPoint:(CGPoint) at{

self = [self init];

if(self){
[self setValidPointInsideCollection:at];
[self setValidIndexPath:[NSIndexPath indexPathForItem:123 inSection:123] forPoint:at];
}

return self;
}
/**
Implementation returns nil. These methods should be stubbed to return valid values
in the tests.
*/

-(UIView *)collectionView{
return _collectionView;
}

-(void) setValidPointInsideCollection:(CGPoint) point{
OCMStub([_collectionView pointInside:point withEvent:nil]).andReturn(YES);
}

-(void) setValidIndexPath:(NSIndexPath *)index forPoint:(CGPoint) at{
UIView *view = OCMPartialMock([[UIView alloc] init]);
OCMStub([self itemAtIndexPath:index]).andReturn(view);
OCMStub([self indexPathForItemAtPoint:at]).andReturn(index);
_items[index] = view;
}

-(NSIndexPath *)indexPathForItemAtPoint:(CGPoint) at{
return nil;
}

-(UIView *)itemAtIndexPath:(NSIndexPath *)index{
-(UIView *)itemAtPoint:(CGPoint) at{
return nil;
}

Expand Down
14 changes: 13 additions & 1 deletion Demo/Tests/I3GestureCoordinatorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,19 @@
describe(@"stopping a valid drag", ^{

__block id defaultDragDataSource;

/// The current collection being draged and its collection view

__block id draggingCollection;
__block id collectionView;
__block id draggingItemView;

/// Immutable origin data

CGPoint dropOrigin = CGPointMake(50, 50);
CGPoint dragOrigin = CGPointMake(10, 10);
NSIndexPath *dragIndex = [NSIndexPath indexPathForItem:0 inSection:0];


beforeEach(^{

Expand All @@ -423,12 +430,17 @@
/// @note that this setup is almost identical to how we setup the coordinator in most of
/// the drag start tests

draggingCollection = OCMPartialMock([[I3CollectionFixture alloc] initWithItemAtPoint:dragOrigin]);
draggingCollection = OCMPartialMock([[I3CollectionFixture alloc] init]);
collectionView = OCMPartialMock([[UIView alloc] init]);
draggingItemView = OCMPartialMock([[UIView alloc] init]);

[coordinator setValue:draggingCollection forKey:@"_currentDraggingCollection"];
[coordinator setValue:[NSValue valueWithCGPoint:dragOrigin] forKey:@"_currentDragOrigin"];
[collections addObject:draggingCollection];

OCMStub([draggingCollection collectionView]).andReturn(collectionView);
OCMStub([draggingCollection indexPathForItemAtPoint:dragOrigin]).andReturn(dragIndex);
OCMStub([draggingCollection itemAtIndexPath:dragIndex]).andReturn(draggingItemView);
OCMStub([panGestureRecognizer state]).andReturn(UIGestureRecognizerStateEnded);
OCMStub([panGestureRecognizer locationInView:[OCMArg any]]).andReturn(dropOrigin);

Expand Down

0 comments on commit f44691e

Please sign in to comment.