Skip to content

Commit

Permalink
Merge branch 'ijameelkhan-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skywinder committed Nov 11, 2014
2 parents e66cc7c + 032b72b commit 9368a59
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import <XCTest/XCTest.h>
#import <CoreActionSheetPicker/CoreActionSheetPicker.h>
#import "AbstractActionSheetPicker+CustomButton.h"

static const int countdownTestInt = 360;
UIView *origin;

@interface ActionSheetDatePickerTestCase : XCTestCase
Expand Down Expand Up @@ -134,6 +136,35 @@ - (void)testPickerWithNilCustomActionSelectorOnButtonNilTargetAndNilString
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testPickerCountDownTimerModeValueWithSelector
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil target:self action:@selector(countDownTest:) origin:origin cancelAction:nil];
_actionSheetDatePicker.countDownDuration = countdownTestInt;
[_actionSheetDatePicker showActionSheetPicker];
[_actionSheetDatePicker pressDoneButton];

XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testPickerCountDownTimerModeValueWithBlock
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil doneBlock:^(ActionSheetDatePicker *picker, id selectedDate, id origin) {
XCTAssertEqualObjects(selectedDate, @(countdownTestInt));
} cancelBlock:nil origin:origin];

_actionSheetDatePicker.countDownDuration = countdownTestInt;
[_actionSheetDatePicker showActionSheetPicker];
UIDatePicker *picker = (UIDatePicker *)_actionSheetDatePicker.pickerView;
[_actionSheetDatePicker pressDoneButton];

XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)countDownTest:(NSNumber *)number
{
XCTAssertEqualObjects(number, @(countdownTestInt));
}

- (void)exampleSelector
{
NSLog(@"Test selector invoked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

- (void)pressFirstCustomButton;

- (void)pressDoneButton;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ - (void)pressFirstCustomButton
);
}

- (void)pressDoneButton
{
//6 items in _actionSheetDatePicker.toolbar.items : [ cancel - custom - separator - title - separator - done ]
//So, check custom button:
UIBarButtonItem *customBarButton = self.toolbar.items[4];
SuppressPerformSelectorLeakWarning (
[customBarButton.target performSelector:customBarButton.action withObject:customBarButton];
);
}

@end
4 changes: 2 additions & 2 deletions Pickers/ActionSheetDatePicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)orig
if (self.onActionSheetDone)
{
if (self.datePickerMode == UIDatePickerModeCountDownTimer)
self.onActionSheetDone(self, @(self.countDownDuration), origin);
self.onActionSheetDone(self, @(((UIDatePicker *)self.pickerView).countDownDuration), origin);
else
self.onActionSheetDone(self, self.selectedDate, origin);

Expand All @@ -136,7 +136,7 @@ - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)orig
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if (self.datePickerMode == UIDatePickerModeCountDownTimer) {
[target performSelector:action withObject:@(self.countDownDuration) withObject:origin];
[target performSelector:action withObject:@(((UIDatePicker *)self.pickerView).countDownDuration) withObject:origin];

} else {
[target performSelector:action withObject:self.selectedDate withObject:origin];
Expand Down

0 comments on commit 9368a59

Please sign in to comment.