Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run ActionSheetPickerTests on Xcode and Travis CI #393

Merged
merged 3 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
language: objective-c
# before_install:
# - brew update
# - brew install xctool
script:
- xcodebuild clean build test -workspace ActionSheetPicker-3.0.xcworkspace -scheme ActionSheetPickerTests -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO

# - xctool -workspace ActionSheetPicker-3.0.xcworkspace -scheme CoreActionSheetPicker build
# - xctool -workspace ActionSheetPicker-3.0.xcworkspace -scheme ActionSheetPickerTests test
osx_image: xcode9

# xcode_workspace: ActionSheetPicker-3.0.xcworkspace
# xcode_scheme: ActionSheetPickerTests
# xcode_sdk: iphonesimulator
script:
- xcodebuild clean build test -workspace ActionSheetPicker-3.0.xcworkspace -scheme ActionSheetPicker -sdk iphonesimulator -destination "platform=iOS Simulator,OS=11.0,name=iPhone X" ONLY_ACTIVE_ARCH=NO

notifications:
email:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import <XCTest/XCTest.h>
#import <CoreActionSheetPicker/ActionSheetStringPicker.h>
#import "AbstractActionSheetPicker+CustomButton.h"
static UIView *origin;

@interface AbstractActionSheetPickerTestCase : XCTestCase
@property(nonatomic, strong) ActionSheetStringPicker *sheetStringPicker;
Expand All @@ -20,19 +19,17 @@ @interface AbstractActionSheetPickerTestCase : XCTestCase
@implementation AbstractActionSheetPickerTestCase
{
NSString *_title;
}

+(void)setUp{
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
origin = topView;
UIView *_origin;
}

- (void)setUp
{
[super setUp];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
_origin = topView;
_title = @"Title";
_sheetStringPicker = [[ActionSheetStringPicker alloc] initWithTitle:_title rows:@[@"1", @"2", @"3"] initialSelection:0 doneBlock:nil cancelBlock:nil origin:origin];
_sheetStringPicker = [[ActionSheetStringPicker alloc] initWithTitle:_title rows:@[@"1", @"2", @"3"] initialSelection:0 doneBlock:nil cancelBlock:nil origin:_origin];
// Put setup code here. This method is called before the invocation of each test method in the class.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

static const int expectedNumberOfRows = 3;

static UIView *origin;

@interface ActionSheetCustomPickerTestCase : XCTestCase <ActionSheetCustomPickerDelegate>

@property(nonatomic, strong) ActionSheetCustomPicker *actionSheetCustomPicker;
Expand All @@ -27,19 +25,17 @@ @interface ActionSheetCustomPickerTestCase : XCTestCase <ActionSheetCustomPicker

@implementation ActionSheetCustomPickerTestCase
{

}

+(void)setUp{
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
origin = topView;
UIView *_origin;
}

- (void)setUp
{
[super setUp];

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
_origin = topView;

self.numberOfComponents = expectedNumberOfComponents;
self.numberOfRowInComponent = expectedNumberOfRows;

Expand Down Expand Up @@ -72,7 +68,7 @@ - (void)testPickerWithInit1
_actionSheetCustomPicker = [[ActionSheetCustomPicker alloc] initWithTarget:self
successAction:nil
cancelAction:nil
origin:origin];
origin:_origin];
XCTAssertNotNil(_actionSheetCustomPicker);
}

Expand All @@ -82,7 +78,7 @@ - (void)testPickerWithInit2
_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@""
delegate:self
showCancelButton:YES
origin:origin];
origin:_origin];
XCTAssertNotNil(_actionSheetCustomPicker);
}
- (void)testPickerWithInit3
Expand All @@ -91,7 +87,7 @@ - (void)testPickerWithInit3
_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@""
delegate:self
showCancelButton:YES
origin:origin
origin:_origin
initialSelections:self.expectedSelections];
XCTAssertNotNil(_actionSheetCustomPicker);
}
Expand All @@ -111,14 +107,14 @@ - (void)testShow1

XCTAssertTrue(_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@"title"
delegate:self
showCancelButton:YES origin:origin]);
showCancelButton:YES origin:_origin]);
}

- (void)testShow2
{
XCTAssertTrue(_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@"" delegate:self
showCancelButton:YES
origin:origin
origin:_origin
initialSelections:self.expectedSelections]);
}

Expand All @@ -127,7 +123,7 @@ - (void)testPickerWithNilInitialSections
{

_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@"title" delegate:self showCancelButton:NO
origin:origin initialSelections:nil ];
origin:_origin initialSelections:nil ];
XCTAssertNotNil(_actionSheetCustomPicker);
}

Expand All @@ -136,7 +132,7 @@ - (void)testPickerWithExpectedInitialSectionsNumberOfSections

NSArray *selections = [self getArrayWithComponents:expectedNumberOfComponents rows:0];
_actionSheetCustomPicker = [ActionSheetCustomPicker showPickerWithTitle:@"title" delegate:self showCancelButton:NO
origin:origin initialSelections:selections];
origin:_origin initialSelections:selections];
XCTAssertNotNil(_actionSheetCustomPicker);
}

Expand All @@ -145,7 +141,7 @@ - (void)testPickerWithInitialSectionsMoreThanNumberOfSectionsFail{
NSArray *selections= [self getArrayWithComponents:expectedNumberOfComponents + 1 rows:expectedNumberOfRows];
XCTAssertThrows([ActionSheetCustomPicker showPickerWithTitle:@""
delegate:self
showCancelButton:YES origin:origin
showCancelButton:YES origin:_origin
initialSelections:selections]);
}

Expand All @@ -154,7 +150,7 @@ - (void)testPickerWithInitialSectionsLessThanNumberOfSectionsFail{
NSArray *selections= [self getArrayWithComponents:expectedNumberOfComponents - 1 rows:expectedNumberOfRows];
XCTAssertThrows([ActionSheetCustomPicker showPickerWithTitle:@""
delegate:self
showCancelButton:YES origin:origin
showCancelButton:YES origin:_origin
initialSelections:selections]);
}

Expand All @@ -163,15 +159,15 @@ - (void)testPickerWithInitialSectionsGreaterRowThanExpectedFail {
NSArray *selections= [self getArrayWithComponents:expectedNumberOfComponents rows:expectedNumberOfRows + 1];
XCTAssertThrows([ActionSheetCustomPicker showPickerWithTitle:@""
delegate:self
showCancelButton:YES origin:origin
showCancelButton:YES origin:_origin
initialSelections:selections]);
}

- (void)testAssertWhenDelegateNil{

XCTAssertThrows([ActionSheetCustomPicker showPickerWithTitle:@""
delegate:nil
showCancelButton:YES origin:origin]);
showCancelButton:YES origin:_origin]);
}

- (void)testWithDelegateAndCustomInitSections{
Expand All @@ -180,7 +176,7 @@ - (void)testWithDelegateAndCustomInitSections{

NSArray *initialSelections = @[@1, @2];

ActionSheetCustomPicker* customPicker = [ActionSheetCustomPicker showPickerWithTitle:@"Select Key & Scale" delegate:testDelegate showCancelButton:NO origin:origin
ActionSheetCustomPicker* customPicker = [ActionSheetCustomPicker showPickerWithTitle:@"Select Key & Scale" delegate:testDelegate showCancelButton:NO origin:_origin
initialSelections:initialSelections];

testDelegate.delegateReturnCorrectValueExpectation = [self expectationWithDescription:@"delegate raised with correct values"];
Expand All @@ -203,7 +199,7 @@ - (void)testAddCustomButton

self.actionSheetCustomPicker = [[ActionSheetCustomPicker alloc] initWithTarget:self successAction:nil
cancelAction:nil
origin:origin];
origin:_origin];
[self.actionSheetCustomPicker addCustomButtonWithTitle:@"Test titile" value:@0];
XCTAssertNotNil(self.actionSheetCustomPicker);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import "AbstractActionSheetPicker+CustomButton.h"

static const int countdownTestInt = 360;
UIView *origin;

@interface ActionSheetDatePickerTestCase : XCTestCase
@property(nonatomic, strong) ActionSheetDatePicker *actionSheetDatePicker;
Expand All @@ -21,20 +20,17 @@ @interface ActionSheetDatePickerTestCase : XCTestCase
@implementation ActionSheetDatePickerTestCase
{
NSString *_title;
}

+ (void)setUp
{
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
origin = topView;
UIView *_origin;
}

- (void)setUp
{
[super setUp];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
_origin = topView;
_title = @"Title";
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeDate selectedDate:[NSDate date] target:nil action:nil origin:origin cancelAction:nil];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeDate selectedDate:[NSDate date] target:nil action:nil origin:_origin cancelAction:nil];
// Put setup code here. This method is called before the invocation of each test method in the class.
}

Expand All @@ -46,37 +42,37 @@ - (void)tearDown

- (void)testInitPicker
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTarget:self successAction:@selector(exampleSelector) cancelAction:@selector(exampleSelector) origin:origin];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTarget:self successAction:@selector(exampleSelector) cancelAction:@selector(exampleSelector) origin:_origin];
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testInitPicker2
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] doneBlock:nil cancelBlock:nil origin:origin];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] doneBlock:nil cancelBlock:nil origin:_origin];
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testInitPicker3
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] target:self action:@selector(exampleSelector) origin:origin];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] target:self action:@selector(exampleSelector) origin:_origin];
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testInitPicker4
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:NSDate.date target:self action:@selector(exampleSelector) origin:origin cancelAction:@selector(exampleSelector)];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:NSDate.date target:self action:@selector(exampleSelector) origin:_origin cancelAction:@selector(exampleSelector)];
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testInitPicker5
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] minimumDate:[NSDate date] maximumDate:[NSDate date] target:self action:@selector(exampleSelector) origin:origin];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:[NSDate date] minimumDate:[NSDate date] maximumDate:[NSDate date] target:self action:@selector(exampleSelector) origin:_origin];
XCTAssertNotNil(_actionSheetDatePicker);
}

- (void)testInitPicker6
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:NSDate.date minimumDate:NSDate.date maximumDate:NSDate.date target:self action:@selector(exampleSelector) cancelAction:@selector(exampleSelector) origin:origin];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:NSDate.date minimumDate:NSDate.date maximumDate:NSDate.date target:self action:@selector(exampleSelector) cancelAction:@selector(exampleSelector) origin:_origin];
XCTAssertNotNil(_actionSheetDatePicker);
}

Expand Down Expand Up @@ -178,7 +174,7 @@ - (void)testPickerWithNilCustomActionSelectorOnButtonNilTargetAndNilString

- (void)testPickerCountDownTimerModeValueWithSelector
{
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil target:self action:@selector(countDownTest:) origin:origin cancelAction:nil];
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test title" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil target:self action:@selector(countDownTest:) origin:_origin cancelAction:nil];
_actionSheetDatePicker.countDownDuration = countdownTestInt;
[_actionSheetDatePicker showActionSheetPicker];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Expand All @@ -196,7 +192,7 @@ - (void)testPickerCountDownTimerModeValueWithBlock
_actionSheetDatePicker = [[ActionSheetDatePicker alloc] initWithTitle:@"Test" datePickerMode:UIDatePickerModeCountDownTimer selectedDate:nil doneBlock:^(ActionSheetDatePicker *picker, id selectedDate, id origin) {
XCTAssertEqualObjects(selectedDate, @(countdownTestInt));
XCTAssertEqualObjects(@(picker.countDownDuration), @(countdownTestInt));
} cancelBlock:nil origin:origin];
} cancelBlock:nil origin:_origin];

_actionSheetDatePicker.countDownDuration = countdownTestInt;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import <XCTest/XCTest.h>
#import <CoreActionSheetPicker/CoreActionSheetPicker.h>
#import "AbstractActionSheetPicker+CustomButton.h"
UIView *origin;

@interface ActionSheetLocalePickerTestCase : XCTestCase
@property(nonatomic, strong) ActionSheetLocalePicker *actionSheetLocalePicker;
Expand All @@ -20,19 +19,16 @@ @interface ActionSheetLocalePickerTestCase : XCTestCase
@implementation ActionSheetLocalePickerTestCase
{
NSString *_title;
}

+(void)setUp{
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
origin = topView;

UIView *_origin;
}

- (void)setUp {
[super setUp];
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
_origin = topView;
_title = @"Title";
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:nil doneBlock:nil cancelBlock:nil origin:origin];
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:nil doneBlock:nil cancelBlock:nil origin:_origin];
// Put setup code here. This method is called before the invocation of each test method in the class.
}

Expand All @@ -43,13 +39,13 @@ - (void)tearDown {

- (void)testPickerWithInitWithDefaultLocale
{
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:nil doneBlock:nil cancelBlock:nil origin:origin];
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:nil doneBlock:nil cancelBlock:nil origin:_origin];
XCTAssertNotNil(_actionSheetLocalePicker);
}

- (void)testPickerWithInitWithLocale
{
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:[NSTimeZone localTimeZone] doneBlock:nil cancelBlock:nil origin:origin];
_actionSheetLocalePicker = [[ActionSheetLocalePicker alloc] initWithTitle:@"Test title" initialSelection:[NSTimeZone localTimeZone] doneBlock:nil cancelBlock:nil origin:_origin];
XCTAssertNotNil(_actionSheetLocalePicker);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
D66F51ADA2999F44F2C282BF /* ActionSheetPickerTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D66F572853325E5592CF945B /* ActionSheetPickerTableViewController.m */; };
D66F51F7B65FE68619FB9762 /* ActionSheetCustomPickerTestDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D66F576CF2A850BF7FFA6085 /* ActionSheetCustomPickerTestDelegate.m */; };
D66F52867C4F51FF504876CB /* AbstractActionSheetPickerTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = D66F5B887137F3C8C61C74D7 /* AbstractActionSheetPickerTestCase.m */; };
D66F56BDCC3CDD653D0A86ED /* TestTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D66F5524D86DF2C1AA77B398 /* TestTableViewController.m */; };
D66F5832537A4862C9F19770 /* TestTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D66F5524D86DF2C1AA77B398 /* TestTableViewController.m */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -346,7 +345,6 @@
buildActionMask = 2147483647;
files = (
1C9444C9197B1C75005F495B /* ActionSheetCustomPickerTestCase.m in Sources */,
D66F56BDCC3CDD653D0A86ED /* TestTableViewController.m in Sources */,
9947CBEB19F811300083B32D /* ActionSheetDatePickerTestCase.m in Sources */,
D66F506882340A184FC6B2C5 /* ActionSheetLocalePickerTestCase.m in Sources */,
D66F52867C4F51FF504876CB /* AbstractActionSheetPickerTestCase.m in Sources */,
Expand Down
Loading