diff --git a/Classes/KIFUITestActor.h b/Classes/KIFUITestActor.h index 7210b6c82..69550343c 100644 --- a/Classes/KIFUITestActor.h +++ b/Classes/KIFUITestActor.h @@ -460,12 +460,44 @@ typedef NS_ENUM(NSUInteger, KIFPullToRefreshTiming) { */ - (void)selectPickerViewRowWithTitle:(NSString *)title inComponent:(NSInteger)component withSearchOrder:(KIFPickerSearchOrder)searchOrder; +/*! + @abstract Selects a value from an input date picker view. + @discussion With a date picker view already visible in the input bar, this step will select the date within the date picker. + @param date The date to be selected in the date picker. + */ +- (void)selectInputDatePickerWithDate:(NSDate *)date; + +/*! + @abstract Selects a value from a date picker view with the provided accessibility label. + @discussion With a date picker view already visible in the input bar, this step will select the date within the date picker. + @param accesibilityLabel The accesibility label associated with the date picker that is to be used. + @param date The date to be selected in the date picker. + */ +- (void)selectDatePickerWithAccesibilityLabel:(NSString *)accesibilityLabel inputDate:(NSDate *)date; + +/*! + @abstract Selects a value from date picker view with the picker type UIDatePickerModeCountDownTimer using the provided accessibility label. + @discussion With a date picker view already visible in the input bar, this step will select the countdown timer values within the date picker. + @param accesibilityLabel The accesibility label associated with the date picker that is to be used. + @param hours The hours in the coundown picker. + @param minutes The minutes in the coundown picker. + */ +- (void)selectCountdownDatePickerWithAccesibilityLabel:(NSString *)accesibilityLabel inputHours:(NSInteger)hours minutes:(NSInteger)minutes; + +/*! + @abstract Selects a value from an input date picker view with the picker type UIDatePickerModeCountDownTimer. + @discussion With a date picker view already visible in the input bar, this step will select the countdown timer values within the date picker. + @param hours The hours in the coundown picker. + @param minutes The minutes in the coundown picker. + */ +- (void)selectInputCountdownDatePickerWithHours:(NSInteger)hours minutes:(NSInteger)minutes; + /*! @abstract Selects a value from a currently visible date picker view. @discussion With a date picker view already visible, this step will select the different rotating wheel values in order of how the array parameter is passed in. After it is done it will hide the date picker. It works with all 4 UIDatePickerMode* modes. The input parameter of type NSArray has to match in what order the date picker is displaying the values/columns. So if the locale is changing the input parameter has to be adjusted. Example: Mode: UIDatePickerModeDate, Locale: en_US, Input param: NSArray *date = @[@"June", @"17", @"1965"];. Example: Mode: UIDatePickerModeDate, Locale: de_DE, Input param: NSArray *date = @[@"17.", @"Juni", @"1965". @param datePickerColumnValues Each element in the NSArray represents a rotating wheel in the date picker control. Elements from 0 - n are listed in the order of the rotating wheels, left to right. */ -- (void)selectDatePickerValue:(NSArray *)datePickerColumnValues; +- (void)selectDatePickerValue:(NSArray *)datePickerColumnValues NS_DEPRECATED_IOS(10_0, 14_0,"Use selectInputCountdownDatePickerWithDate: or selectCountdownDatePickerWithAccesibilityLabel: instead."); /*! @abstract Selects a value from a currently visible date picker view, according to the search order specified. diff --git a/Classes/KIFUITestActor.m b/Classes/KIFUITestActor.m index 14da10489..eebcf2e4d 100644 --- a/Classes/KIFUITestActor.m +++ b/Classes/KIFUITestActor.m @@ -43,6 +43,12 @@ @interface KIFUITestActor () static BOOL KIFUITestActorAnimationsEnabled = YES; +@interface UIDatePicker() + +- (void)_emitValueChanged; + +@end + @implementation KIFUITestActor + (void)initialize @@ -676,18 +682,167 @@ - (void)selectPickerViewRowWithTitle:(NSString *)title inComponent:(NSInteger)co [self selectPickerViewRowWithTitle:title inComponent:component fromPicker:nil withSearchOrder:searchOrder]; } +- (void)selectCountdownDatePickerWithAccesibilityLabel:(NSString *)accesibilityLabel inputHours:(NSInteger)hours minutes:(NSInteger)minutes +{ + UIDatePicker *datePicker = (UIDatePicker *)[self waitForViewWithAccessibilityLabel:accesibilityLabel]; + NSAssert([datePicker isKindOfClass:[UIDatePicker class]], @"Did not find Date picker with label %@", accesibilityLabel); + [self selectCountdownDatePicker:datePicker inputHours:hours minutes:minutes]; +} + +- (void)selectInputCountdownDatePickerWithHours:(NSInteger)hours minutes:(NSInteger)minutes +{ + UIDatePicker *datePicker = [[[[UIApplication sharedApplication] datePickerWindow] subviewsWithClassName:@"UIDatePicker"] lastObject]; + [self selectCountdownDatePicker:datePicker inputHours:hours minutes:minutes]; +} + +- (void)selectCountdownDatePicker:(UIDatePicker *)datePicker inputHours:(NSInteger)hours minutes:(NSInteger)minutes +{ + NSAssert(datePicker.datePickerMode == UIDatePickerModeCountDownTimer, @"Date picker was not of type countdown timer."); + datePicker.countDownDuration = (hours * 60 * 60) + (minutes * 60); + [datePicker _emitValueChanged]; +} + +- (void)selectDatePickerWithAccesibilityLabel:(NSString *)accesibilityLabel inputDate:(NSDate *)date +{ + UIDatePicker *datePicker = (UIDatePicker *)[self waitForViewWithAccessibilityLabel:accesibilityLabel]; + NSAssert([datePicker isKindOfClass:[UIDatePicker class]], @"Did not find Date picker with label %@", accesibilityLabel); + [self selectDatePicker:datePicker inputDate:date]; +} + +- (void)selectInputDatePickerWithDate:(NSDate *)date +{ + UIDatePicker *datePicker = [[[[UIApplication sharedApplication] datePickerWindow] subviewsWithClassName:@"UIDatePicker"] lastObject]; + [self selectDatePicker:datePicker inputDate:date]; +} + +- (void)selectDatePicker:(UIDatePicker *)datePicker inputDate:(NSDate *)date +{ + NSAssert(datePicker.datePickerMode != UIDatePickerModeCountDownTimer, @"Date picker was not in expected date picking mode mode. Instead got countdown timer."); + + datePicker.date = date; + [datePicker _emitValueChanged]; +} + +// date formatter to be used so we don't keep re-allocating a new one. ++ (NSDateFormatter *)__kifDateFormatter +{ + static dispatch_once_t onceToken; + static NSDateFormatter *__kifDateFormatter = nil; + dispatch_once(&onceToken, ^{ + __kifDateFormatter = [[NSDateFormatter alloc] init]; + }); + + return __kifDateFormatter; +} + +// uses the date pickers locale to find the ordering of day month and year. ++ (NSArray*)dateOrderForDatePicker:(UIDatePicker *)datePicker +{ + NSString *dateFormatString = [NSDateFormatter dateFormatFromTemplate:@"yMMMMd" options:0 locale:datePicker.locale]; + __block BOOL hasAddedYear = NO; + __block BOOL hasAddedMonth = NO; + __block BOOL hasAddedDay = NO; + NSMutableArray *dateOrder = [NSMutableArray array]; + [dateFormatString enumerateSubstringsInRange:NSMakeRange(0, dateFormatString.length) + options:NSStringEnumerationByComposedCharacterSequences + usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { + if([substring containsString:@"y"] && !hasAddedYear) { + hasAddedYear = YES; + [dateOrder addObject:@"y"]; + } + + if([substring containsString:@"d"] && !hasAddedDay) { + hasAddedDay = YES; + [dateOrder addObject:@"d"]; + } + + if([substring containsString:@"M"] && !hasAddedMonth) { + hasAddedMonth = YES; + [dateOrder addObject:@"M"]; + } + }]; + + return [dateOrder copy]; +} + - (void)selectDatePickerValue:(NSArray *)datePickerColumnValues { - [self selectPickerValue:datePickerColumnValues fromPicker:nil pickerType:KIFUIDatePicker withSearchOrder:KIFPickerSearchForwardFromStart]; + [self selectDatePickerValue:datePickerColumnValues withSearchOrder:KIFPickerSearchForwardFromStart]; } + - (void)selectDatePickerValue:(NSArray *)datePickerColumnValues withSearchOrder:(KIFPickerSearchOrder)searchOrder { - [self selectPickerValue:datePickerColumnValues fromPicker:nil pickerType:KIFUIDatePicker withSearchOrder:searchOrder]; + UIDatePicker *datePicker = [[[[UIApplication sharedApplication] datePickerWindow] subviewsWithClassNameOrSuperClassName:@"UIDatePicker"] lastObject]; + [self selectDatePickerValue:datePickerColumnValues fromPicker:datePicker withSearchOrder:KIFPickerSearchForwardFromStart]; } -- (void)selectDatePickerValue:(NSArray *)datePickerColumnValues fromPicker:(UIPickerView *)picker withSearchOrder:(KIFPickerSearchOrder)searchOrder +- (void)selectDatePickerValue:(NSArray *)datePickerColumnValues fromPicker:(UIDatePicker *)datePicker withSearchOrder:(KIFPickerSearchOrder)searchOrder { - [self selectPickerValue:datePickerColumnValues fromPicker:picker pickerType:KIFUIDatePicker withSearchOrder:searchOrder]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + NSArray *dateOrder = [self.class dateOrderForDatePicker:datePicker]; + + // Backwards compatibility while migrating away from this deprecated API. + if(datePicker.datePickerMode == UIDatePickerModeDate) { + // using the date order from the current locale grab use the index that corresponds to the date unit (month, day, or year) + // to grab the correct value from the provided array. + for (int i = 0; i < datePickerColumnValues.count; i++) { + if([dateOrder[i] isEqualToString:@"y"]) { + dateComponents.year = [datePickerColumnValues[i] integerValue]; + } else if ([dateOrder[i] isEqualToString:@"M"]) { + dateComponents.month = [self.class.__kifDateFormatter.monthSymbols containsObject:datePickerColumnValues[i]] ? [self.class.__kifDateFormatter.monthSymbols indexOfObject:datePickerColumnValues[i]] + 1 : NSNotFound ; + } else if ([dateOrder[i] isEqualToString:@"d"]) { + dateComponents.day = [datePickerColumnValues[i] integerValue]; + } + } + } else if (datePicker.datePickerMode == UIDatePickerModeTime) { + dateComponents.minute = [datePickerColumnValues[1] integerValue]; + + BOOL isPM = NO; + if(datePickerColumnValues.count > 2 && [datePickerColumnValues.lastObject isEqualToString:self.class.__kifDateFormatter.PMSymbol]) { + isPM = YES; + } + + dateComponents.hour = isPM ? [datePickerColumnValues[0] integerValue] + 12 : [datePickerColumnValues[0] integerValue]; + } else if (datePicker.datePickerMode == UIDatePickerModeDateAndTime) { + NSAssert(datePickerColumnValues.count == 3 || datePickerColumnValues.count == 4, @"Invalid datePickerColumnValue count. Expected 3 or 4 got %@", @(datePickerColumnValues.count)); + NSString *dayOfWeekMonthDay = datePickerColumnValues[0]; + // in a date time picker the first value is either "Today" or something like "Tue Aug 12" so seperate by a space to + // grab the correct values from it. + NSArray*dayOfWeekMonthDayComponents = [dayOfWeekMonthDay componentsSeparatedByString:@" "]; + NSDateComponents *currentDateComponents = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:datePicker.date]; + // if the string components of the first value is 1 we assume it's saying "Today" and use the current dates components + if(dayOfWeekMonthDayComponents.count == 1) { + NSDateComponents *todayDateComponents = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:[NSDate date]]; + dateComponents = todayDateComponents; + } else { + for (NSString *component in dayOfWeekMonthDayComponents) { + // check if the month and day of the component is found in the column and set the components respectively. + if ([self.class.__kifDateFormatter.monthSymbols containsObject:component]) { + dateComponents.month = [self.class.__kifDateFormatter.monthSymbols indexOfObject:component] + 1; + } else if ([self.class.__kifDateFormatter.shortMonthSymbols containsObject:component]) { + dateComponents.month = [self.class.__kifDateFormatter.shortMonthSymbols indexOfObject:component] + 1; + } else if ([component integerValue] != 0) { // days can't be zero and if a string is not a number it will default to zero. + dateComponents.day = [component integerValue]; + } + } + } + + BOOL isPM = NO; + if(datePickerColumnValues.count == 4 && [datePickerColumnValues.lastObject isEqualToString:self.class.__kifDateFormatter.PMSymbol]) { + isPM = YES; + } + + dateComponents.hour = isPM ? [datePickerColumnValues[1] integerValue] + 12 : [datePickerColumnValues[1] integerValue]; + dateComponents.minute = [datePickerColumnValues[2] integerValue]; + dateComponents.year = currentDateComponents.year; + } + + if (datePicker.datePickerMode != UIDatePickerModeCountDownTimer) { + [self selectDatePicker:datePicker inputDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; + } else { + NSAssert(datePickerColumnValues.count == 2, @"Invalid datePickerColumnValue count. Expect 2 got %@", @(datePickerColumnValues.count)); + [self selectCountdownDatePicker:datePicker inputHours:[datePickerColumnValues[0] integerValue] minutes:[datePickerColumnValues[1] integerValue]]; + } } - (void)selectPickerViewRowWithTitle:(NSString *)title inComponent:(NSInteger)component fromPicker:(UIPickerView *)picker diff --git a/KIF Tests/PickerTests.m b/KIF Tests/PickerTests.m index 4ee410121..a3d7bf0a6 100644 --- a/KIF Tests/PickerTests.m +++ b/KIF Tests/PickerTests.m @@ -18,29 +18,51 @@ - (void)afterEach - (void)testSelectingDateInPast { [tester tapViewWithAccessibilityLabel:@"Date Selection"]; - NSArray *date = @[@"June", @"17", @"1965"]; - // If the UIDatePicker LocaleIdentifier would be de_DE then the date to set - // would look like this: NSArray *date = @[@"17.", @"Juni", @"1965" - [tester selectDatePickerValue:date]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 6; + dateComponents.day = 17; + dateComponents.year = 1965; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Jun 17, 1965" traits:UIAccessibilityTraitNone]; } - (void)testSelectingDateInFuture { [tester tapViewWithAccessibilityLabel:@"Date Selection"]; - NSArray *date = @[@"December", @"31", @"2030"]; - [tester selectDatePickerValue:date]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 12; + dateComponents.day = 31; + dateComponents.year = 2030; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Dec 31, 2030" traits:UIAccessibilityTraitNone]; } - (void)testSelectingDateTime { [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; - NSArray *dateTime = @[@"Jun 17", @"6", @"43", @"AM"]; - [tester selectDatePickerValue:dateTime]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 6; + dateComponents.day = 17; + dateComponents.hour = 6; + dateComponents.minute = 43; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; } +- (void)testSelectingCurrentDateTime +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:-360]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"hh mm a"; + NSArray *dateValues = [@[@"Today"] arrayByAddingObjectsFromArray:[[dateFormatter stringFromDate:date] componentsSeparatedByString:@" "]]; + dateFormatter.dateFormat = @"MMM d, hh:mm a"; + NSString *expectedDate = [dateFormatter stringFromDate:date]; + [tester selectDatePickerValue:dateValues]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:expectedDate traits:UIAccessibilityTraitNone]; +} + + - (void)testSelectingDateTimeBackwards { [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; @@ -67,22 +89,71 @@ - (void)testSelectingDateTimeFromCurrentForwards [tester waitForViewWithAccessibilityLabel:@"Limited Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; } -- (void)testSelectingTime -{ - [tester tapViewWithAccessibilityLabel:@"Time Selection"]; - NSArray *time = @[@"7", @"44", @"AM"]; - [tester selectDatePickerValue:time]; - [tester waitForViewWithAccessibilityLabel:@"Time Selection" value:@"7:44 AM" traits:UIAccessibilityTraitNone]; -} - - (void)testSelectingCountdown { [tester tapViewWithAccessibilityLabel:@"Countdown Selection"]; - NSArray *countdown = @[@"4", @"10"]; - [tester selectDatePickerValue:countdown]; + [tester selectInputCountdownDatePickerWithHours:4 minutes:10]; [tester waitForViewWithAccessibilityLabel:@"Countdown Selection" value:@"15000.000000" traits:UIAccessibilityTraitNone]; } +- (void)test_wheelsSelectingDateInPast +{ + [tester tapViewWithAccessibilityLabel:@"Date Selection"]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 6; + dateComponents.day = 17; + dateComponents.year = 1965; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; + [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Jun 17, 1965" traits:UIAccessibilityTraitNone]; +} + +- (void)test_wheelsSelectingDateInFuture +{ + [tester tapViewWithAccessibilityLabel:@"Date Selection"]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 12; + dateComponents.day = 31; + dateComponents.year = 2030; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; + [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Dec 31, 2030" traits:UIAccessibilityTraitNone]; +} + +- (void)test_wheelsSelectingDateTime +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 6; + dateComponents.day = 17; + dateComponents.hour = 6; + dateComponents.minute = 43; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_wheelsSelectingCurrentDateTime +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:-360]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"hh mm a"; + NSArray *dateValues = [@[@"Today"] arrayByAddingObjectsFromArray:[[dateFormatter stringFromDate:date] componentsSeparatedByString:@" "]]; + dateFormatter.dateFormat = @"MMM d, hh:mm a"; + NSString *expectedDate = [dateFormatter stringFromDate:date]; + [tester selectDatePickerValue:dateValues]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:expectedDate traits:UIAccessibilityTraitNone]; +} + +- (void)test_wheelsSelectingTime +{ + [tester tapViewWithAccessibilityLabel:@"Time Selection"]; + + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.hour = 7; + dateComponents.minute = 44; + [tester selectInputDatePickerWithDate:[[NSCalendar currentCalendar] dateFromComponents:dateComponents]]; + [tester waitForViewWithAccessibilityLabel:@"Time Selection" value:@"7:44 AM" traits:UIAccessibilityTraitNone]; +} + - (void)testSelectingAPickerRow { [tester selectPickerViewRowWithTitle:@"Echo"]; @@ -129,4 +200,88 @@ - (void)testSelectingRowInComponent [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Dec 17, 2030" traits:UIAccessibilityTraitNone]; } +#pragma mark - Deprecated Method testing + +- (void)test_deprectedSelectingDateInPast +{ + [tester tapViewWithAccessibilityLabel:@"Date Selection"]; + NSArray *date = @[@"June", @"17", @"1965"]; + // If the UIDatePicker LocaleIdentifier would be de_DE then the date to set + // would look like this: NSArray *date = @[@"17.", @"Juni", @"1965" + [tester selectDatePickerValue:date]; + [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Jun 17, 1965" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingDateInFuture +{ + [tester tapViewWithAccessibilityLabel:@"Date Selection"]; + NSArray *date = @[@"December", @"31", @"2030"]; + [tester selectDatePickerValue:date]; + [tester waitForViewWithAccessibilityLabel:@"Date Selection" value:@"Dec 31, 2030" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingDateTime +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSArray *dateTime = @[@"Jun 17", @"6", @"43", @"AM"]; + [tester selectDatePickerValue:dateTime]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingCurrentDateTime +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:-360]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"hh mm a"; + NSArray *dateValues = [@[@"Today"] arrayByAddingObjectsFromArray:[[dateFormatter stringFromDate:date] componentsSeparatedByString:@" "]]; + dateFormatter.dateFormat = @"MMM d, hh:mm a"; + NSString *expectedDate = [dateFormatter stringFromDate:date]; + [tester selectDatePickerValue:dateValues]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:expectedDate traits:UIAccessibilityTraitNone]; +} + + +- (void)test_deprectedSelectingDateTimeBackwards +{ + [tester tapViewWithAccessibilityLabel:@"Date Time Selection"]; + NSArray *dateTime = @[@"Jun 17", @"6", @"43", @"AM"]; + [tester selectDatePickerValue:dateTime withSearchOrder:KIFPickerSearchBackwardFromEnd]; + [tester waitForViewWithAccessibilityLabel:@"Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingDateTimeFromCurrentBackwards +{ + [tester tapViewWithAccessibilityLabel:@"Limited Date Time Selection"]; + NSArray *dateTime = @[@"Jun 17", @"6", @"43", @"AM"]; + // Since Limited Date Picker Time had a minimum date, default search order from start will fail. + [tester selectDatePickerValue:dateTime withSearchOrder:KIFPickerSearchBackwardFromCurrentValue]; + [tester waitForViewWithAccessibilityLabel:@"Limited Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingDateTimeFromCurrentForwards +{ + [tester tapViewWithAccessibilityLabel:@"Limited Date Time Selection"]; + NSArray *dateTime = @[@"Jun 17", @"6", @"43", @"AM"]; + // Since Limited Date Picker Time had a maximum date, From End Backwards will fail too. + [tester selectDatePickerValue:dateTime withSearchOrder:KIFPickerSearchForwardFromCurrentValue]; + [tester waitForViewWithAccessibilityLabel:@"Limited Date Time Selection" value:@"Jun 17, 06:43 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingTime +{ + [tester tapViewWithAccessibilityLabel:@"Time Selection"]; + NSArray *time = @[@"7", @"44", @"AM"]; + [tester selectDatePickerValue:time]; + [tester waitForViewWithAccessibilityLabel:@"Time Selection" value:@"7:44 AM" traits:UIAccessibilityTraitNone]; +} + +- (void)test_deprectedSelectingCountdown +{ + [tester tapViewWithAccessibilityLabel:@"Countdown Selection"]; + NSArray *countdown = @[@"4", @"10"]; + [tester selectDatePickerValue:countdown]; + [tester waitForViewWithAccessibilityLabel:@"Countdown Selection" value:@"15000.000000" traits:UIAccessibilityTraitNone]; +} + @end diff --git a/Test Host/Base.lproj/MainStoryboard.storyboard b/Test Host/Base.lproj/MainStoryboard.storyboard index 29aefacca..11db79200 100644 --- a/Test Host/Base.lproj/MainStoryboard.storyboard +++ b/Test Host/Base.lproj/MainStoryboard.storyboard @@ -1,9 +1,10 @@ - + + - - + + @@ -11,11 +12,11 @@ - + - + @@ -27,157 +28,157 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - @@ -187,17 +188,17 @@ - + - + - @@ -207,17 +208,17 @@ - + - + - @@ -227,17 +228,17 @@ - + - + - @@ -251,35 +252,35 @@ - + - + - + - + - + - @@ -289,40 +290,40 @@ - + - + - + - + - + - + @@ -345,7 +346,7 @@ - + @@ -355,25 +356,29 @@ - + + + + + - + - - + @@ -382,18 +387,18 @@ - + - + - + - + @@ -401,30 +406,30 @@ - + - + - + - + - + @@ -433,13 +438,13 @@ - + - + - + @@ -454,647 +459,647 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1104,36 +1109,36 @@ - + - + - - + - + @@ -1158,16 +1163,16 @@ - + - + - + @@ -1182,11 +1187,11 @@ - @@ -1208,51 +1213,55 @@ - + + + + + - + - - + + - - + + - - + - + - - + @@ -1333,42 +1342,49 @@ - + + + + + - + - - - - - - + + + + - - - + @@ -1426,25 +1446,31 @@ - + + + + + - + - - + + + - - + + + @@ -1455,8 +1481,9 @@ - - + + + @@ -1469,37 +1496,38 @@ - - @@ -1640,22 +1669,26 @@ Line Break - + + + + + - + - - + + - + @@ -1664,23 +1697,27 @@ Line Break - + + + + + - + - - + + - + - + @@ -1689,21 +1726,25 @@ Line Break - + + + + + - + - - + + - + @@ -1712,7 +1753,7 @@ Line Break - + @@ -1721,7 +1762,7 @@ Line Break - + @@ -1731,10 +1772,10 @@ Line Break - + - + @@ -1745,17 +1786,21 @@ Line Break - + - - + + + + + + - + @@ -1764,16 +1809,7 @@ Line Break - - - - - - - - - - + @@ -1782,7 +1818,7 @@ Line Break - + @@ -1791,7 +1827,7 @@ Line Break - + @@ -1800,7 +1836,7 @@ Line Break - + @@ -1809,13 +1845,36 @@ Line Break + + + + + + + + + + + + + + + + + + + + + - + + + @@ -1824,59 +1883,63 @@ Line Break - + + + + + - + - - - - - + @@ -1896,25 +1959,29 @@ Line Break - + + + + + - + - - + @@ -1925,12 +1992,201 @@ Line Break - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Test Host/PickerController.m b/Test Host/PickerController.m index 1790073b9..cc675eab1 100644 --- a/Test Host/PickerController.m +++ b/Test Host/PickerController.m @@ -6,11 +6,15 @@ @interface PickerController : UIViewController