From 2d6413925e2f89326bfe78bc35be49504a7e50a7 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 16:05:47 -0700 Subject: [PATCH 01/20] Initial commit with SLAccessibilityContainer and working tests --- .../Tests/SLTableViewCellChildElementsTest.m | 598 ++++++++++++++++++ ...eViewCellChildElementsTestViewController.m | 155 +++++ ...iewCellChildElementsTestViewController.xib | 34 + .../Tests/heart_empty_icon&32.png | Bin 0 -> 3855 bytes Integration Tests/Tests/heart_icon&32.png | Bin 0 -> 3510 bytes .../Classes/Internal/NSObject+SLVisibility.m | 7 +- .../SLAccessibilityContainer.h | 32 + .../SLAccessibilityContainer.m | 100 +++ Sources/Subliminal.h | 1 + Subliminal.xcodeproj/project.pbxproj | 36 ++ 10 files changed, 962 insertions(+), 1 deletion(-) create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTest.m create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib create mode 100755 Integration Tests/Tests/heart_empty_icon&32.png create mode 100755 Integration Tests/Tests/heart_icon&32.png create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m new file mode 100644 index 0000000..5bd24fa --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -0,0 +1,598 @@ +// +// SLTableViewCellChildElementsTest.m +// Subliminal +// +// Created by Jordan Zucker on 3/20/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLIntegrationTest.h" + +@interface focus_SLTableViewCellChildElementsTest : SLIntegrationTest + +@end + +@implementation focus_SLTableViewCellChildElementsTest + ++ (NSString *)testCaseViewControllerClassName { + return @"SLTableViewCellChildElementsTestViewController"; +} + +// If you override set-up methods, +// you must call super at the beginning of your implementations. + +// If you override tear-down methods, +// you must call super at the *end* of your implementations. + +- (void)testTapBroadMatchingTableViewCellButton { + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + + SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; +// SLLogAsync(@"favoritButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton recursive is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +} + +//- (void)testOriginalHackMatchingTableViewCell +//{ +//// [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { +// +// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { +// +// id accessibilityParent = [obj slAccessibilityParent]; +// +// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); +// while (accessibilityParent && ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"]) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); +// +// } +// +// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); +// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; +// +// } +// +// return NO; +// +// } withDescription:@"searching for favoritebutton"]; +// +//// SLLogAsync(@"favoriteButton is %@", favoriteButton); +//// +//// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [favoriteButton isValidAndVisible]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +//// SLLogAsync(@"testing"); +//// SLLogAsync(@"favoriteButton is %@", favoriteButton); +//// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +//// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +//// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +//// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +// +// +//} + +//- (void)testOriginalHackMatchingTableViewCellWithNoAXMatching +//{ +//// [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { +// +// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { +// +// id accessibilityParent = [obj slAccessibilityParent]; +// +// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); +// while (accessibilityParent && (![accessibilityParent isKindOfClass:[UITableViewCell class]] || ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"])) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); +// +// } +// +// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); +// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; +// +// } +// +// return NO; +// +// } withDescription:@"searching for favoritebutton"]; +// +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// +// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// //SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +// +// +//} + +- (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView +{ +// [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { + + if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { + + id accessibilityParent = [obj slAccessibilityParent]; + + //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); + while (accessibilityParent && ![[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]) { + + accessibilityParent = [accessibilityParent slAccessibilityParent]; + //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); + + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; + + while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:[UITableView class]]) { + doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; + } + + if (doubleAccessibilityParent) { + return YES; + } + else { + return NO; + } + + + } + + return NO; + + } withDescription:@"searching for favoritebutton"]; + +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// +// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; + + +} + +- (void)testMatchingTableViewCellWithNewMethod +{ + // [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// cell2.parentElementType = SLTableViewCellElement; +// //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; + SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // + // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); + // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); + // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + + // SLLogAsync(@"testing"); + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); + // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); + // SLLogAsync(@"now log element tree for favorite button"); + // [favoriteButton logElementTree]; + + +} + + +//- (void)testMatchingTableViewCellWithNewMethod +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodTVCSubclass +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLTableViewCell *cell2 = [SLTableViewCell parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + + +//- (void)testMatchingTableViewCellWithNewMethod +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:UIAccessibilityTraitButton inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodAnyTraits +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodAnyTraitsAndElement +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLElement *favoriteButton = [SLElement elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + + +@end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m new file mode 100644 index 0000000..25d0f08 --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m @@ -0,0 +1,155 @@ +// +// SLTableViewCellChildElementsTestViewController.m +// Subliminal +// +// Created by Jordan Zucker on 3/20/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTestCaseViewController.h" + +#import + +@interface SLTableViewCellChildElementsTestViewController : SLTestCaseViewController + +@end + +@interface SLTableViewCellChildElementsTestViewController () +@property (nonatomic, weak) IBOutlet UITableView *tableView; +@property (nonatomic, strong) NSArray *tableViewElements; +@property (nonatomic, strong) NSMutableArray *tableViewFavorites; +@end + +@implementation SLTableViewCellChildElementsTestViewController + ++ (NSString *)nibNameForTestCase:(SEL)testCase { + return @"SLTableViewCellChildElementsTestViewController"; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + _tableViewElements = @[@"Cell 0", @"Cell 1", @"Cell 2", @"Cell 3"]; + _tableViewFavorites = [[NSMutableArray alloc] initWithObjects:@(NO), @(NO), @(NO), @(NO), nil]; + + // Do any additional setup after loading the view from its nib. + // Test case specific configuration is best done using app hooks + // triggered from -[SLTableViewCellChildElementsTests setUpTestCaseWithSelector:]. +} + +- (instancetype)initWithTestCaseWithSelector:(SEL)testCase { + self = [super initWithTestCaseWithSelector:testCase]; + if (self) { + // Register for app hooks, e.g. + // [[SLTestController sharedTestController] registerTarget:<#(id)#> forAction:<#(SEL)#>]; + } + return self; +} + +// Deregister for app hooks, if any +//- (void)dealloc { +// [[SLTestController sharedTestController] deregisterTarget:self]; +//} + +//#pragma mark - App hooks +// Put any app hooks below here + +#pragma mark - UIButton method + +- (IBAction)pressButton:(id)sender +{ + UIButton *favoriteButton = (UIButton *)sender; + NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + [self setFavoriteButton:favoriteButton withFavoriteStatus:(![oldFavoriteBool boolValue])]; + // NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + // NSNumber *updatedFavoriteBool; + // NSString *updatedFavoriteButtonAccessibilityValue; + // UIImage *updatedFavoriteButtonImage; + // if ([oldFavoriteBool boolValue] == YES) { + // updatedFavoriteBool = @(NO); + // updatedFavoriteButtonAccessibilityValue = @"off"; + // updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_empty_icon&32.png"]; + // + // } + // else { + // updatedFavoriteBool = @(YES); + // updatedFavoriteButtonAccessibilityValue = @"on"; + // updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_icon&32.png"]; + // } + // [_tableViewFavorites setObject:updatedFavoriteBool atIndexedSubscript:favoriteButton.tag]; + // favoriteButton.accessibilityValue = updatedFavoriteButtonAccessibilityValue; + // [favoriteButton setImage:updatedFavoriteButtonImage forState:UIControlStateNormal]; + + // if ([favoriteButton.titleLabel.text isEqualToString:@"Favorite"]) { + // [favoriteButton setTitle:@"Unfavorite" forState:UIControlStateNormal]; + // } + // else { + // [favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; + // } + //[favoriteButton setImage:[UIImage imageNamed:@"heart_icon&32.png"] forState:UIControlStateNormal]; +} + +- (void) setFavoriteButton:(UIButton *)favoriteButton withFavoriteStatus:(BOOL)favoriteBool +{ + //NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + // NSNumber *updatedFavoriteBool; + NSString *updatedFavoriteButtonAccessibilityValue; + UIImage *updatedFavoriteButtonImage; + if (favoriteBool == YES) { + // updatedFavoriteBool = @(NO); + updatedFavoriteButtonAccessibilityValue = @"on"; + updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_icon&32.png"]; + + } + else { + // updatedFavoriteBool = @(YES); + updatedFavoriteButtonAccessibilityValue = @"off"; + updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_empty_icon&32.png"]; + } + [_tableViewFavorites setObject:@(favoriteBool) atIndexedSubscript:favoriteButton.tag]; + favoriteButton.accessibilityValue = updatedFavoriteButtonAccessibilityValue; + [favoriteButton setImage:updatedFavoriteButtonImage forState:UIControlStateNormal]; +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [_tableViewElements count]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + } + + cell.textLabel.text = [_tableViewElements objectAtIndex:indexPath.row]; + + //UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + //[favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; + UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; + //[favoriteButton setImage:[UIImage imageNamed:@"heart_empty_icon&32.png"] forState:UIControlStateNormal]; + favoriteButton.accessibilityLabel = @"Favorite"; + //favoriteButton.accessibilityValue = @"off"; + favoriteButton.tag = indexPath.row; + + favoriteButton.frame = CGRectMake(160.0f, 5.0f, 32.0f, 32.0f); + [self setFavoriteButton:favoriteButton withFavoriteStatus:[[_tableViewFavorites objectAtIndex:indexPath.row] boolValue]]; + [favoriteButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside]; + [cell addSubview:favoriteButton]; + + cell.accessibilityLabel = cell.textLabel.text; + cell.accessibilityValue = cell.textLabel.text; + + return cell; +} + +@end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib new file mode 100644 index 0000000..4483677 --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Integration Tests/Tests/heart_empty_icon&32.png b/Integration Tests/Tests/heart_empty_icon&32.png new file mode 100755 index 0000000000000000000000000000000000000000..9c324dcae4870583d1e9e693c693dac84baa343d GIT binary patch literal 3855 zcmb_f4Ommx8IIyFYO7PH_UYPdbZU#qO#%^emw@?UfRf-yG)$-Ea_>oUCAl}=djkQt zYK4j-N}YCnioflAWctkN{1-(KEZ9-4RUdVAFhw2y%QH80t<#-*^J7A(U46y_fpgCH zz2AG@?>pZ)ET3UX8xs3UtVALil96u8hQATvXFxyr$rTs>QzD7&N7-`t9CIc{FdjKh zGI>Dm_juvDM50acdvPKk@JJqTQnXHb|8SiYp-7$7t~M*oUL$Z(>BTIt7F%pYaXz6T zr76j=T0aH>Jb=d$zsF5;m|rIqaWVL}FpWwP(S*;}N%cZNB*#1hF)}Pb)N+N4P)t!E zQrX z78c42s*Ui{$e!jWK6UB<-QwyN3!5sA{AZIJ`0yGkDG8Fss;;3DN`tADz!}+kEzv|QW>XE!tx2(o6T4T&G9%*fDDsP z3c=+RMPeFbyjq{APD)a#l2RdtCP`y7D)dUdNue^Rjj9ND6GQlf1cuznALgC~D}|zQ z_Y1)Yg^OsPDKeA8oxlcI4=1h!idygH1EavuO$n8ZxpCSF_bVfT1NXUkX|j<8I8PM- zcnUophUO4G&$CpXPdE%R3quRjfF&s0jkqZS&>YaB!WnT>!C2xb6ih3WRWMK8SZPTD zBZOcK8^O{F7DTg5PJ^PlAv*#fgpcDH55hByI}c|OiV*mbfTNsrPb5NETC`gzAvAOg zo$-k9A>P48@LeL=DHb?b+yf9O5fe?QCnh0SkxBQ+0vpbkHy;qe1c`mjfIGVh5!}77 z>mD~9%4>3zKGAf-HW6UlcbHH#4_Hz6o+J(<`Kaf!aekixk8}CqbVhRtj6za~>P0Fg zC>Q9kKRkv1?>djBqK)jym>7#;jSReM2tI>$Fyc)TZ9~mu-FAkBH(|t`x(^qz7!5&saW7fsH+#f?b0x`X2-m?;{MR2=+Ril*0=EDRy|+T?0$hi{24o zghCg9(9ge*!p4LPc4y&gLxsnZaGeD!;9IHr)=mStGetGIz#M!a!Iv2tewx8S_;Ckl z7>tEax6x_VMex}-hEL7mt&D>[H-ywJp=%LX`EwBR$K72bw|kv`LA!<`bFi{cRY z&AWiuo)HHN8}_pnE>tm`1A$cz;Q%j3F6Q4j4slEZPB@K{=N(W4UPQ8po5;c-Ccsh! z;?2b^Y~8gP;-w1D*$4&Tl;p(-9vSxN73iBT06rrqz`Z!hoFy%NC6buD43pmG|LTbS zq~+4oq5C&1e$bpRcnY9ec+l)n6@=X@^a|esaaw^GpfpYTA_TSbIjd?$%%;{bp4~Fx}mLY z-mKz;l$0-C{a{_`CG#NuC-2HVTT(};`n~nq>WSIEb0L6i-%0+wM++0#pB0F*Y*O=z$ zpkMgwN_XU}-FR;9;F@^@t)G^amEGR6XV1V>m8({rZ@f`ID`tOke7x1((A?Zyb6)@3 zuE8I+__Z7FtX+^h=gd4~tl?MH_a|JOU+)-(J!x2cy6h!v*ZA_&c&E=Yu()` zmdxDh)Yxei^;@J-3{gg?bTbi`fF#mPumC0;_fPvH5#hjziCW!sSIl}P_T)Sr5P!_M|qliDxJ>rSwz z3d{FcTBlw$kGmZ6a(U^TFWU}opFiUexBio@X-T#RU!FbN*tzuI9S>&5UH<&)Rifpa zas0!xt*xG7&HmZT&bV&fyt!@rzI8P0Z$Jr6fO|$CN$Kt+vI=)fi j|9jSn^>w2k!KoIgI_iv1#0M%?t&dS0Q9<3iJVyD z{%^nk-+%XxriMkcatm__f|%v2^ETuE!1z7;Ec{oG$Bz?4?pZ>h6}9^78BUR`EU&af zYfMt{Izc$Eh^Z{s0TF12AwhPL-#xdF1Oo3OTgv@5zv_Wup)Rh$CGmy;7w_O4Jb6V` zt~17900|-%#3WJHnV5?-aT)yGn5IZznxGCB={5p_R(})lC>jLiR-1*hU1kH9(N?;& ztfHc#1lVn~jk4J(+HRpMm{L1qvw`FfS(OW%8Xshuy;mlK;gO3BBcw7E6^%x%(Ne3T zg(%wLa2OzVy9HZV^e!2(F^jBUU_c}=yin&fK}CWh0|S$7S0czol6W1Yb|R_GLMV*% zbO>2bYKGOLVysHhRvV?6HdLl3&!t_|h$fnxc#eW1l%R}s>_%tV`&7i0VHpio(w>+c zXL{<0r!pSe*eVg zl9a_tN41?;*JO^y6;Ka!sgP=hx)RYiSlfvuy1)#IsU;G?_*tz3;z|r?5tv$H{J6S! z7O`FyVbyTq&=wnQv6lzvQl`9|q3L29jmsxx@Aor4Sx2nQL7&$}VsNV<@JwZ`*XyV( zudKA&D{C=^qtfB=*xa<+YqQssd+ZtRUWJPo2~4^3|INJ-SBfCB;-p}V!UfLLiY(RH z5DY*~(#@4bQM*Ny7$t_HU{o?AvT_LT*TTaf8xav%<OP%qI@G0KOM(}qcwFnvv zYODkSmPpAaG#--_tjT0-WP^NeHqIQ`HX^hHn!ec##Qnuq{NM$1=XyM+2 z8+)CAyN1^FF9b60BL=4k_c|A;vz?GPJ3Q{Li6vpOcSIT?8ip8p;`=CV%!P4xHm)|x zcq|#$S+WBDlA6ElG?6=RR+CH2;Rh0anNjJd86Kn`cTmQ`H2ie?>A5vE_}N#0YFp6~ zC5WP|28qNA%`CcR$nssw4nn8#HZ+Xf^??8zA_8GS2l#`+&}`2jsNsfvx`i86jOSot zRR=mmR`71e$RNh?8aU}R5)&OzfG;9T#!b|q058;pPV?r{mmk^LkMU}a=WK=oc#4=D z!RKe6D8#;X2HbyCP zZ4Lb{_u=zKrr)_R>~fFpxP18;`jpb6IbXd-_H4f7=!?hqmOb#u8-sz;Qy)9#+*9%6 zvE@JB^x1)&L!WC!y`jFsp=Fy-ZDjN3_C9_6<3BGxpLjNsUsT=5yuN<__c?E#d1T-z13m#g$k>!PlF zX=us5kCZL-t%8X*ryuN!E39(DosRaj0%fPCcc@N~}|N6%eact(vY4h8v*5rTFxH@O$ zKu+PB;m=ild}Ifu6wlnlAIK*?FOe($Yq z+v{ibRew7r@X^b1(fj_Zx4+d=GVjwVZ3B+A^&c)+UgKppzObeE$uH5PqZg4|FW#R! z+|lA2?fq`m2cH~=m)?I*ciFlfvqrnCwr-kPec`>n>F@68on5*I9cq7~|L*xeYzUI8 zPZZBNc5uz`MXrL`a`E7&%l6ejxbXIo%^}a5!;9Yt&s{rmol3tt18cmkqv8AbhPn&M zYrj>u7wp-#>pd~pa?Vk;vLv^szbAj8_a#N%wAeGyv|zBZFW$fVzAw5?E;@NfkG}8g b?in`XsyI0K^O1F1jk5C9Hh6c`wDtT6rTv@G literal 0 HcmV?d00001 diff --git a/Sources/Classes/Internal/NSObject+SLVisibility.m b/Sources/Classes/Internal/NSObject+SLVisibility.m index 06095a1..71474ab 100644 --- a/Sources/Classes/Internal/NSObject+SLVisibility.m +++ b/Sources/Classes/Internal/NSObject+SLVisibility.m @@ -133,7 +133,12 @@ - (BOOL)slAccessibilityIsVisible { // if another element comes before us/our parent in the array // (thus is z-ordered before us/our parent) // and contains our hitpoint, it covers us - if (CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; +// SLLogAsync(@"element is %@", [element description]); +// SLLogAsync(@"element is %@", element); +// SLLogAsync(@"element frame is %@", NSStringFromCGRect([element accessibilityFrame])); +// SLLogAsync(@"testPoint is %@", NSStringFromCGPoint(testPoint)); +// SLLogAsync(@"container frame is %@", NSStringFromCGRect([container accessibilityFrame])); + if (![NSStringFromClass([element class]) isEqualToString:@"UITableTextAccessibilityElement"] && CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; } // we should eventually reach a container that is a view diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h new file mode 100644 index 0000000..902fb36 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -0,0 +1,32 @@ +// +// SLAccessibilityContainer.h +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLElement.h" + +typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { + SLTableViewAccessibilityContainer, + SLCollectionViewAccessibilityContainer +}; + +@interface SLAccessibilityContainer : SLElement + +@property (nonatomic) SLElement *containerElement; +@property (nonatomic, assign) SLAccessibilityContainerType containerType; + +- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + ++ (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + ++ (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; ++ (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; ++ (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + +- (id)childElementMatching:(SLElement *)childElement; ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement ofContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + +@end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m new file mode 100644 index 0000000..0fa5525 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -0,0 +1,100 @@ +// +// SLAccessibilityContainer.m +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLAccessibilityContainer.h" +#import "SLUIAElement+Subclassing.h" +#import "NSObject+SLAccessibilityHierarchy.h" + +@implementation SLAccessibilityContainer + +- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + self = [super init]; + if (self) { + _containerElement = element; + _containerType = accessibilityContainerType; + } + return self; +} + ++ (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:element andContainerType:accessibilityContainerType]; +} + ++ (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityIdentifier:identifer] andContainerType:accessibilityContainerType]; +} ++ (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label] andContainerType:accessibilityContainerType]; +} ++ (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label value:value traits:traits] andContainerType:accessibilityContainerType]; +} + +- (id)childElementMatching:(SLElement *)childElement +{ + return [SLElement elementMatching:^BOOL(NSObject *obj) { + // first match child element + if ([childElement matchesObject:obj]) { + + id accessibilityParent = [obj slAccessibilityParent]; + + //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); + // then look for child element having matching parent + while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { + + accessibilityParent = [accessibilityParent slAccessibilityParent]; + //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); + + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; + + Class compareClass; + switch (_containerType) { + case SLTableViewAccessibilityContainer: + compareClass = [UITableView class]; + break; + case SLCollectionViewAccessibilityContainer: + compareClass = [UICollectionView class]; + break; + + default: + compareClass = [UIView class]; + break; + } + + while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:compareClass]) { + doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; + } + + if (doubleAccessibilityParent) { + return YES; + } + else { + return NO; + } + + + } + + return NO; + } withDescription:@"searching for child element"]; +} ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement ofContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + SLAccessibilityContainer *container = [SLAccessibilityContainer containerWithElement:containerElement andContainerType:accessibilityContainerType]; + return [container childElementMatching:childElement]; +} + +@end diff --git a/Sources/Subliminal.h b/Sources/Subliminal.h index b56a432..6f8c254 100644 --- a/Sources/Subliminal.h +++ b/Sources/Subliminal.h @@ -28,6 +28,7 @@ #import "SLElement.h" #import "NSObject+SLAccessibilityDescription.h" #import "NSObject+SLAccessibilityHierarchy.h" +#import "SLAccessibilityContainer.h" #import "SLStaticElement.h" #import "SLAlert.h" #import "SLButton.h" diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index d291a12..ea8867e 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -41,6 +41,13 @@ 50F2B7C818E9C0D700F21635 /* SLDispatchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F2B7C718E9C0D700F21635 /* SLDispatchTests.m */; }; 50F3E18C1783A5CB00C6BD1B /* SLGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F3E18A1783A5CB00C6BD1B /* SLGeometry.h */; }; 50F3E18E1783A60100C6BD1B /* SLGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F3E18B1783A5CB00C6BD1B /* SLGeometry.m */; }; + 97068F8C18ECB5AF005FE660 /* heart_empty_icon&32.png in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */; }; + 97068F8D18ECB5AF005FE660 /* heart_icon&32.png in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8818ECB5AF005FE660 /* heart_icon&32.png */; }; + 97068F8E18ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */; }; + 97068F8F18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */; }; + 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; + 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -274,6 +281,13 @@ 50F2B7C718E9C0D700F21635 /* SLDispatchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDispatchTests.m; sourceTree = ""; }; 50F3E18A1783A5CB00C6BD1B /* SLGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLGeometry.h; sourceTree = ""; }; 50F3E18B1783A5CB00C6BD1B /* SLGeometry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLGeometry.m; sourceTree = ""; }; + 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heart_empty_icon&32.png"; sourceTree = ""; }; + 97068F8818ECB5AF005FE660 /* heart_icon&32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heart_icon&32.png"; sourceTree = ""; }; + 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCellChildElementsTest.m; sourceTree = ""; }; + 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCellChildElementsTestViewController.m; sourceTree = ""; }; + 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLTableViewCellChildElementsTestViewController.xib; sourceTree = ""; }; + 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAccessibilityContainer.h; sourceTree = ""; }; + 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -518,6 +532,18 @@ name = "SLGeometry Tests"; sourceTree = ""; }; + 97068F9418ECB5B2005FE660 /* SLTableViewCellChildElements Tests */ = { + isa = PBXGroup; + children = ( + 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */, + 97068F8818ECB5AF005FE660 /* heart_icon&32.png */, + 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */, + 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */, + 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */, + ); + name = "SLTableViewCellChildElements Tests"; + sourceTree = ""; + }; CAC388011641CD4800F995F9 /* Internal */ = { isa = PBXGroup; children = ( @@ -772,6 +798,8 @@ F0695DD8160138DF000B05D0 /* SLUIAElement.m */, F0A04E1B1749F70F002C7520 /* SLElement.h */, F0A04E1C1749F70F002C7520 /* SLElement.m */, + 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */, + 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */, F043469D175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.h */, F043469E175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.m */, CAC3883D1643503C00F995F9 /* NSObject+SLAccessibilityHierarchy.h */, @@ -896,6 +924,7 @@ F0AC80BE16BB542400C5D5C0 /* Tests */ = { isa = PBXGroup; children = ( + 97068F9418ECB5B2005FE660 /* SLTableViewCellChildElements Tests */, DB2627D817B96704009DA3A6 /* SLStatusBar Tests */, 50A59BD317848CEE002A863A /* SLGeometry Tests */, F07DA31F16E439B7004C2282 /* SLAlert Tests */, @@ -1008,6 +1037,7 @@ F0695E1E16014491000B05D0 /* SLTest.h in Headers */, F0695E1F16014491000B05D0 /* SLTerminal.h in Headers */, F0695E2016014491000B05D0 /* SLUIAElement.h in Headers */, + 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */, F0695E2116014491000B05D0 /* SLLogger.h in Headers */, F0271AFF162E0B950098F5F2 /* SLTestController+AppHooks.h in Headers */, CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */, @@ -1218,10 +1248,13 @@ F043A9C7172A160600A4FD1D /* SLElementVisibilityTest.html in Resources */, F08005591730762C00198F6F /* Inklings~iPhone.webarchive in Resources */, F0C4DB4817388ACA00111149 /* SLElementVisibilityTestSuperviewWithVisibleSubview.xib in Resources */, + 97068F8C18ECB5AF005FE660 /* heart_empty_icon&32.png in Resources */, 064B6F55173B13E9004AB1BF /* SLElementVisibilityTestCoveredByClearRegion.xib in Resources */, + 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */, 064B6FC7173DCE9A004AB1BF /* SLElementVisibilityWithSubviews.xib in Resources */, F0C27CDF1741694900335A41 /* SLElementStateTestMidpointCovered.xib in Resources */, F0C27CE917416EC400335A41 /* SLElementStateTestCompletelyCovered.xib in Resources */, + 97068F8D18ECB5AF005FE660 /* heart_icon&32.png in Resources */, F00800C9174B3349001927AC /* SLButtonTestViewController.xib in Resources */, F00F3B5E1778E05100119580 /* SLElementTapTestScrollViewCases.xib in Resources */, F00F3B6717790B4C00119580 /* SLStaticElementTestScrollView.xib in Resources */, @@ -1305,6 +1338,7 @@ F0C07A501704009E00C93F93 /* SLWindow.m in Sources */, F0C07A541704011400C93F93 /* SLKeyboard.m in Sources */, F0C07A58170401E500C93F93 /* SLWebView.m in Sources */, + 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */, F05C4F91171406EF00A381BC /* SLTerminal+ConvenienceFunctions.m in Sources */, F05C51E6171C8AE000A381BC /* SLMainThreadRef.m in Sources */, F0A04E1E1749F70F002C7520 /* SLElement.m in Sources */, @@ -1326,6 +1360,7 @@ F0AC80A016BB299500C5D5C0 /* main.m in Sources */, F0AC80A416BB299500C5D5C0 /* SLIntegrationTestsAppDelegate.m in Sources */, F0AC80BD16BB50FF00C5D5C0 /* SLTestsViewController.m in Sources */, + 97068F8E18ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m in Sources */, F0AC80C416BC355D00C5D5C0 /* SLTerminalTest.m in Sources */, F0AC80C116BB559F00C5D5C0 /* SLIntegrationTest.m in Sources */, F0AC80C816BC367E00C5D5C0 /* SLTestViewController.m in Sources */, @@ -1366,6 +1401,7 @@ DB2627DE17B96727009DA3A6 /* SLStatusBarTest.m in Sources */, F078C0491808BF24000767D2 /* SLWebViewTest.m in Sources */, DB2627DF17B96727009DA3A6 /* SLStatusBarTestViewController.m in Sources */, + 97068F8F18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m in Sources */, 50A59BD81784908D002A863A /* SLGeometryTest.m in Sources */, 50A59BDB178490C2002A863A /* SLGeometryTestViewController.m in Sources */, ); From a0413dec8526f2607ad29a59da606592768fc333 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 16:15:06 -0700 Subject: [PATCH 02/20] Added SLTableViewCell subclass of SLAccessibilityContainer --- .../Classes/Internal/NSObject+SLVisibility.m | 5 --- .../User Interface Elements/SLTableViewCell.h | 24 +++++++++++ .../User Interface Elements/SLTableViewCell.m | 40 +++++++++++++++++++ Subliminal.xcodeproj/project.pbxproj | 8 ++++ 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m diff --git a/Sources/Classes/Internal/NSObject+SLVisibility.m b/Sources/Classes/Internal/NSObject+SLVisibility.m index 71474ab..ef2e690 100644 --- a/Sources/Classes/Internal/NSObject+SLVisibility.m +++ b/Sources/Classes/Internal/NSObject+SLVisibility.m @@ -133,11 +133,6 @@ - (BOOL)slAccessibilityIsVisible { // if another element comes before us/our parent in the array // (thus is z-ordered before us/our parent) // and contains our hitpoint, it covers us -// SLLogAsync(@"element is %@", [element description]); -// SLLogAsync(@"element is %@", element); -// SLLogAsync(@"element frame is %@", NSStringFromCGRect([element accessibilityFrame])); -// SLLogAsync(@"testPoint is %@", NSStringFromCGPoint(testPoint)); -// SLLogAsync(@"container frame is %@", NSStringFromCGRect([container accessibilityFrame])); if (![NSStringFromClass([element class]) isEqualToString:@"UITableTextAccessibilityElement"] && CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; } diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h new file mode 100644 index 0000000..4f4e1af --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -0,0 +1,24 @@ +// +// SLTableViewCell.h +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLAccessibilityContainer.h" + +@interface SLTableViewCell : SLAccessibilityContainer + +- (instancetype)initTableViewCellWithElement:(SLElement *)element; + ++ (instancetype)tableViewCellWithElement:(SLElement *)element; + ++ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer; ++ (instancetype)tableViewCellWithLabel:(NSString *)label; ++ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; + +//- (id)childElementMatching:(SLElement *)childElement; ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement; + +@end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m new file mode 100644 index 0000000..2fbf440 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -0,0 +1,40 @@ +// +// SLTableViewCell.m +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTableViewCell.h" + +@implementation SLTableViewCell + +- (instancetype)initTableViewCellWithElement:(SLElement *)element +{ + return [self initContainerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; +} + ++ (instancetype)tableViewCellWithElement:(SLElement *)element +{ + return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; +} + ++ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer +{ + return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; +} ++ (instancetype)tableViewCellWithLabel:(NSString *)label +{ + return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; +} ++ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits +{ + return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; +} ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement +{ + return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; +} + +@end diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index ea8867e..47c4d04 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; }; + 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -288,6 +290,8 @@ 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLTableViewCellChildElementsTestViewController.xib; sourceTree = ""; }; 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAccessibilityContainer.h; sourceTree = ""; }; 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; + 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLTableViewCell.h; sourceTree = ""; }; + 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCell.m; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -800,6 +804,8 @@ F0A04E1C1749F70F002C7520 /* SLElement.m */, 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */, 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */, + 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */, + 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */, F043469D175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.h */, F043469E175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.m */, CAC3883D1643503C00F995F9 /* NSObject+SLAccessibilityHierarchy.h */, @@ -1035,6 +1041,7 @@ F0695E1C16014491000B05D0 /* Subliminal.h in Headers */, F0695E1D16014491000B05D0 /* SLTestController.h in Headers */, F0695E1E16014491000B05D0 /* SLTest.h in Headers */, + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */, F0695E1F16014491000B05D0 /* SLTerminal.h in Headers */, F0695E2016014491000B05D0 /* SLUIAElement.h in Headers */, 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */, @@ -1334,6 +1341,7 @@ CA75E78516697C0000D57E92 /* SLDevice.m in Sources */, F0C07A391703F95B00C93F93 /* SLAlert.m in Sources */, F0C07A481703FEF600C93F93 /* SLButton.m in Sources */, + 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */, F0C07A4C1704002100C93F93 /* SLTextField.m in Sources */, F0C07A501704009E00C93F93 /* SLWindow.m in Sources */, F0C07A541704011400C93F93 /* SLKeyboard.m in Sources */, From 8d21da398f77aec30c841334e2968f783ca7de56 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 17:06:59 -0700 Subject: [PATCH 03/20] Added test for TableViewCell methods --- .../Tests/SLTableViewCellChildElementsTest.m | 61 +++++++++++++++++++ Sources/Subliminal.h | 1 + Subliminal.xcodeproj/project.pbxproj | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index 5bd24fa..e474177 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -341,6 +341,67 @@ - (void)testMatchingTableViewCellWithNewMethod // [favoriteButton logElementTree]; +} + +- (void)testMatchingTableViewCellWithNewMethodSubclass +{ + // [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; + // SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + // cell2.parentElementType = SLTableViewCellElement; + // //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; + // SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; + // SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; + SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // + // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); + // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); + // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + + // SLLogAsync(@"testing"); + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); + // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); + // SLLogAsync(@"now log element tree for favorite button"); + // [favoriteButton logElementTree]; + + } diff --git a/Sources/Subliminal.h b/Sources/Subliminal.h index 6f8c254..5edcc8b 100644 --- a/Sources/Subliminal.h +++ b/Sources/Subliminal.h @@ -29,6 +29,7 @@ #import "NSObject+SLAccessibilityDescription.h" #import "NSObject+SLAccessibilityHierarchy.h" #import "SLAccessibilityContainer.h" +#import "SLTableViewCell.h" #import "SLStaticElement.h" #import "SLAlert.h" #import "SLButton.h" diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index 47c4d04..4d5246a 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -48,7 +48,7 @@ 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; - 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; }; + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; From 350b00197c0394ac682fa32356d974aff262d495 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 17:11:59 -0700 Subject: [PATCH 04/20] Cleaned up comments --- .../Tests/SLTableViewCellChildElementsTest.m | 480 +----------------- .../SLAccessibilityContainer.m | 2 - 2 files changed, 2 insertions(+), 480 deletions(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index e474177..ef3b023 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -28,10 +28,6 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; -// SLLogAsync(@"favoritButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton recursive is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -42,7 +38,6 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -55,155 +50,10 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; } -//- (void)testOriginalHackMatchingTableViewCell -//{ -//// [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { -// -// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { -// -// id accessibilityParent = [obj slAccessibilityParent]; -// -// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); -// while (accessibilityParent && ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"]) { -// -// accessibilityParent = [accessibilityParent slAccessibilityParent]; -// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); -// -// } -// -// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); -// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; -// -// } -// -// return NO; -// -// } withDescription:@"searching for favoritebutton"]; -// -//// SLLogAsync(@"favoriteButton is %@", favoriteButton); -//// -//// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [favoriteButton isValidAndVisible]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -//// SLLogAsync(@"testing"); -//// SLLogAsync(@"favoriteButton is %@", favoriteButton); -//// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -//// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -//// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -//// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; -// -// -//} - -//- (void)testOriginalHackMatchingTableViewCellWithNoAXMatching -//{ -//// [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { -// -// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { -// -// id accessibilityParent = [obj slAccessibilityParent]; -// -// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); -// while (accessibilityParent && (![accessibilityParent isKindOfClass:[UITableViewCell class]] || ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"])) { -// -// accessibilityParent = [accessibilityParent slAccessibilityParent]; -// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); -// -// } -// -// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); -// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; -// -// } -// -// return NO; -// -// } withDescription:@"searching for favoritebutton"]; -// -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// -// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// //SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; -// -// -//} - - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView { -// [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { @@ -211,11 +61,9 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView id accessibilityParent = [obj slAccessibilityParent]; - //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); while (accessibilityParent && ![[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; - //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); } @@ -240,13 +88,7 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView } withDescription:@"searching for favoritebutton"]; -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// -// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -256,7 +98,6 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -269,43 +110,17 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; - - } -- (void)testMatchingTableViewCellWithNewMethod +- (void)testMatchingTableViewCellWithAccessibilityContainerMethod { - // [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// cell2.parentElementType = SLTableViewCellElement; -// //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // - // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); - // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); - // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -317,7 +132,6 @@ - (void)testMatchingTableViewCellWithNewMethod [UIAElement(favoriteButton) isValidAndVisible]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -330,43 +144,17 @@ - (void)testMatchingTableViewCellWithNewMethod [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - - // SLLogAsync(@"testing"); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); - // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); - // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); - // SLLogAsync(@"now log element tree for favorite button"); - // [favoriteButton logElementTree]; - - } -- (void)testMatchingTableViewCellWithNewMethodSubclass +- (void)testMatchingTableViewCellWithTableViewCellMethodSubclass { - // [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; - // SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - // cell2.parentElementType = SLTableViewCellElement; - // //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; - // SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; - // SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // - // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); - // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); - // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -378,7 +166,6 @@ - (void)testMatchingTableViewCellWithNewMethodSubclass [UIAElement(favoriteButton) isValidAndVisible]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -391,269 +178,6 @@ - (void)testMatchingTableViewCellWithNewMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - - // SLLogAsync(@"testing"); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); - // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); - // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); - // SLLogAsync(@"now log element tree for favorite button"); - // [favoriteButton logElementTree]; - - } - -//- (void)testMatchingTableViewCellWithNewMethod -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodTVCSubclass -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLTableViewCell *cell2 = [SLTableViewCell parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - - -//- (void)testMatchingTableViewCellWithNewMethod -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:UIAccessibilityTraitButton inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodAnyTraits -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodAnyTraitsAndElement -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLElement *favoriteButton = [SLElement elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - - @end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 0fa5525..6106913 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -48,12 +48,10 @@ - (id)childElementMatching:(SLElement *)childElement id accessibilityParent = [obj slAccessibilityParent]; - //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); // then look for child element having matching parent while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; - //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); } From de8f395575a20819079f5fbe13534b28f68c465f Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Fri, 4 Apr 2014 14:10:12 -0700 Subject: [PATCH 05/20] Updated SLAccessibilityContainer to be true subclass. --- .../Tests/SLNavigationBarTests.m | 58 ++++++++++++++++ .../SLNavigationBarTestsViewController.m | 67 +++++++++++++++++++ .../SLNavigationBarTestsViewController.xib | 33 +++++++++ .../Tests/SLTableViewCellChildElementsTest.m | 34 ++++++++++ ...eViewCellChildElementsTestViewController.m | 1 - .../SLAccessibilityContainer.h | 8 +-- .../SLAccessibilityContainer.m | 57 ++++++++++------ .../User Interface Elements/SLTableViewCell.h | 3 +- .../User Interface Elements/SLTableViewCell.m | 43 ++++++++++-- Subliminal.xcodeproj/project.pbxproj | 20 ++++++ 10 files changed, 293 insertions(+), 31 deletions(-) create mode 100644 Integration Tests/Tests/SLNavigationBarTests.m create mode 100644 Integration Tests/Tests/SLNavigationBarTestsViewController.m create mode 100644 Integration Tests/Tests/SLNavigationBarTestsViewController.xib diff --git a/Integration Tests/Tests/SLNavigationBarTests.m b/Integration Tests/Tests/SLNavigationBarTests.m new file mode 100644 index 0000000..228e6a2 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTests.m @@ -0,0 +1,58 @@ +// +// SLNavigationBarTests.m +// Subliminal +// +// Created by Jordan Zucker on 4/4/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLIntegrationTest.h" + +@interface focus_SLNavigationBarTests : SLIntegrationTest + +@end + +@implementation focus_SLNavigationBarTests + ++ (NSString *)testCaseViewControllerClassName { + return @"SLNavigationBarTestsViewController"; +} + +// If you override set-up methods, +// you must call super at the beginning of your implementations. + +// If you override tear-down methods, +// you must call super at the *end* of your implementations. + +- (void)testRightButtonBroadMatching { + SLButton *rightButton = [SLButton elementWithAccessibilityLabel:@"Right"]; + SLAssertTrue([UIAElement(rightButton) isValidAndVisible], @"Right button didn't appear"); + + [UIAElement(rightButton) tap]; +} + +- (void)testRightButtonWithNewMethod +{ + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLLogAsync(@"navBar is %@", navBar); + SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); + SLButton *rightButton = [navBar childElementMatching:[SLButton elementWithAccessibilityLabel:@"Right"]]; + SLAssertTrue([UIAElement(rightButton) isValidAndVisible], @"Couldn't find right button bar"); + + [UIAElement(rightButton) tap]; + +} + +- (void)testTitleLabel +{ + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLLogAsync(@"navBar is %@", navBar); + SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); + SLElement *title = [navBar childElementMatching:[SLElement elementWithAccessibilityLabel:@"Testing" value:nil traits:UIAccessibilityTraitStaticText]]; + SLAssertTrue([UIAElement(title) isValidAndVisible], @"title isn't valid and visible"); + SLLogAsync(@"title is %@", title.label); + SLAssertTrue([UIAElement(title.label) isEqualToString:@"Testing"], @"title doesn't match expected string"); + +} + +@end diff --git a/Integration Tests/Tests/SLNavigationBarTestsViewController.m b/Integration Tests/Tests/SLNavigationBarTestsViewController.m new file mode 100644 index 0000000..e4b7d52 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTestsViewController.m @@ -0,0 +1,67 @@ +// +// SLNavigationBarTestsViewController.m +// Subliminal +// +// Created by Jordan Zucker on 4/4/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTestCaseViewController.h" + +#import + +@interface SLNavigationBarTestsViewController : SLTestCaseViewController + +@end + +@interface SLNavigationBarTestsViewController () +// Connect IBOutlets here. +@property (nonatomic, weak) IBOutlet UINavigationBar *navBar; +@end + +@implementation SLNavigationBarTestsViewController + ++ (NSString *)nibNameForTestCase:(SEL)testCase { + return @"SLNavigationBarTestsViewController"; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Do any additional setup after loading the view from its nib. + // Test case specific configuration is best done using app hooks + // triggered from -[SLNavigationBarTests setUpTestCaseWithSelector:]. + UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBarButtonItemStylePlain target:self action:@selector(tapRightButton:)]; + rightButton.accessibilityLabel = @"Right"; + _navBar.topItem.rightBarButtonItem = rightButton; + + _navBar.accessibilityIdentifier = @"NavigationBar"; + + _navBar.topItem.title = @"Testing"; + _navBar.topItem.title.isAccessibilityElement = YES; + _navBar.topItem.title.accessibilityLabel = _navBar.topItem.title; +} + +- (IBAction)tapRightButton:(id)sender +{ + NSLog(@"hey"); +} + +- (instancetype)initWithTestCaseWithSelector:(SEL)testCase { + self = [super initWithTestCaseWithSelector:testCase]; + if (self) { + // Register for app hooks, e.g. + // [[SLTestController sharedTestController] registerTarget:<#(id)#> forAction:<#(SEL)#>]; + } + return self; +} + +// Deregister for app hooks, if any +//- (void)dealloc { +// [[SLTestController sharedTestController] deregisterTarget:self]; +//} + +//#pragma mark - App hooks +// Put any app hooks below here + +@end diff --git a/Integration Tests/Tests/SLNavigationBarTestsViewController.xib b/Integration Tests/Tests/SLNavigationBarTestsViewController.xib new file mode 100644 index 0000000..518af47 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTestsViewController.xib @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index ef3b023..24e6c36 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -180,4 +180,38 @@ - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; } +- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex +{ + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +} + @end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m index 25d0f08..79e0043 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m @@ -132,7 +132,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } cell.textLabel.text = [_tableViewElements objectAtIndex:indexPath.row]; - //UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; //[favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h index 902fb36..fde9779 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -10,16 +10,16 @@ typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { SLTableViewAccessibilityContainer, - SLCollectionViewAccessibilityContainer + SLCollectionViewAccessibilityContainer, + SLNavigationBarContainer, + SLToolbarContainer, + SLTabBarContainer }; @interface SLAccessibilityContainer : SLElement -@property (nonatomic) SLElement *containerElement; @property (nonatomic, assign) SLAccessibilityContainerType containerType; -- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; - + (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 6106913..4f9a98f 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -12,32 +12,38 @@ @implementation SLAccessibilityContainer -- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType -{ - self = [super init]; - if (self) { - _containerElement = element; - _containerType = accessibilityContainerType; - } - return self; -} - + (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:element andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [element matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityIdentifier:identifer] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityIdentifier:identifer] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityLabel:label] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label value:value traits:traits] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityLabel:label value:value traits:traits] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } - (id)childElementMatching:(SLElement *)childElement @@ -49,15 +55,11 @@ - (id)childElementMatching:(SLElement *)childElement id accessibilityParent = [obj slAccessibilityParent]; // then look for child element having matching parent - while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { + while (accessibilityParent && ![self matchesObject:accessibilityParent]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; } - - - id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; - Class compareClass; switch (_containerType) { case SLTableViewAccessibilityContainer: @@ -66,11 +68,26 @@ - (id)childElementMatching:(SLElement *)childElement case SLCollectionViewAccessibilityContainer: compareClass = [UICollectionView class]; break; - + case SLNavigationBarContainer: + compareClass = [UINavigationBar class]; + break; + case SLTabBarContainer: + compareClass = [UITabBar class]; + break; + case SLToolbarContainer: + compareClass = [UIToolbar class]; + break; + default: compareClass = [UIView class]; break; } + if ((_containerType == SLNavigationBarContainer) || (_containerType == SLTabBarContainer) || (_containerType == SLToolbarContainer)) { + return [accessibilityParent isKindOfClass:compareClass]; + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:compareClass]) { doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index 4f4e1af..ee771a8 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -10,7 +10,6 @@ @interface SLTableViewCell : SLAccessibilityContainer -- (instancetype)initTableViewCellWithElement:(SLElement *)element; + (instancetype)tableViewCellWithElement:(SLElement *)element; @@ -18,6 +17,8 @@ + (instancetype)tableViewCellWithLabel:(NSString *)label; + (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; +//+ (instancetype)tableViewCellAtIndexPath:(NSIndexPath *)indexPath; + //- (id)childElementMatching:(SLElement *)childElement; + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2fbf440..2291fe6 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -7,14 +7,11 @@ // #import "SLTableViewCell.h" +#import "SLUIAElement+Subclassing.h" +#import "NSObject+SLAccessibilityHierarchy.h" @implementation SLTableViewCell -- (instancetype)initTableViewCellWithElement:(SLElement *)element -{ - return [self initContainerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; -} - + (instancetype)tableViewCellWithElement:(SLElement *)element { return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; @@ -37,4 +34,40 @@ + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLEleme return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; } +//+ (id)tableViewCellAtIndexPath:(NSIndexPath *)indexPath +//{ +// SLTableViewCell *cell = [SLTableViewCell elementMatching:^BOOL(NSObject *obj) { +// id accessibilityParent = [obj slAccessibilityParent]; +// +// // then look for child element having matching parent +// while (accessibilityParent && ![accessibilityParent isKindOfClass:[UITableView class]]) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// +// } +// if ([accessibilityParent isKindOfClass:[UITableView class]]) { +// //NSIndexPath * +// NSLog(@"----------------------------------------------- Properties for object %@", self); +// +// @autoreleasepool { +// unsigned int numberOfProperties = 0; +// objc_property_t *propertyArray = class_copyPropertyList([self class], &numberOfProperties); +// for (NSUInteger i = 0; i < numberOfProperties; i++) { +// objc_property_t property = propertyArray[i]; +// NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)]; +// NSLog(@"Property %@ Value: %@", name, [self valueForKey:name]); +// SLLogAsync(@"Property %@ Value: %@", name, [self valueForKey:name]); +// } +// free(propertyArray); +// } +// NSLog(@"-----------------------------------------------"); +// return NO; +// //return [indexPath compare:[]]; +// } +// return NO; +// } withDescription:@"container"]; +// cell.containerType = SLTableViewAccessibilityContainer; +// return cell; +//} + @end diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index 4d5246a..f07b87a 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -50,6 +50,9 @@ 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; + 97AC17D718EF2B0F00B42B66 /* SLNavigationBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */; }; + 97AC17D818EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */; }; + 97AC17D918EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -292,6 +295,9 @@ 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLTableViewCell.h; sourceTree = ""; }; 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCell.m; sourceTree = ""; }; + 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLNavigationBarTests.m; sourceTree = ""; }; + 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLNavigationBarTestsViewController.m; sourceTree = ""; }; + 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLNavigationBarTestsViewController.xib; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -548,6 +554,16 @@ name = "SLTableViewCellChildElements Tests"; sourceTree = ""; }; + 97AC17DD18EF2B1B00B42B66 /* New Group */ = { + isa = PBXGroup; + children = ( + 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */, + 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */, + 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */, + ); + name = "New Group"; + sourceTree = ""; + }; CAC388011641CD4800F995F9 /* Internal */ = { isa = PBXGroup; children = ( @@ -949,6 +965,7 @@ F013798E16D0843B009BAF22 /* SLTerminal Tests */, F078C0431808BF0D000767D2 /* SLWebView Tests */, F089F98E17458B7400DF1F25 /* SLWindow Tests */, + 97AC17DD18EF2B1B00B42B66 /* New Group */, ); path = Tests; sourceTree = ""; @@ -1250,6 +1267,7 @@ F0E80D8816DB2CEB00945D25 /* SLElementVisibilityTestElementContainerHidden.xib in Resources */, F0E80D8916DB2CEB00945D25 /* SLElementVisibilityTestElementCovered.xib in Resources */, F0E80D8A16DB2CEB00945D25 /* SLElementVisibilityTestElementOffscreen.xib in Resources */, + 97AC17D918EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib in Resources */, F043A9BE1729CFFE00A4FD1D /* SLElementVisibilityTestElementHidden.xib in Resources */, F043A9C01729EFD100A4FD1D /* SLElementVisibilityTestUserInteractionDisabled.xib in Resources */, F043A9C7172A160600A4FD1D /* SLElementVisibilityTest.html in Resources */, @@ -1365,6 +1383,7 @@ buildActionMask = 2147483647; files = ( 2C903BC017F525E700555317 /* SLSwitchTest.m in Sources */, + 97AC17D818EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m in Sources */, F0AC80A016BB299500C5D5C0 /* main.m in Sources */, F0AC80A416BB299500C5D5C0 /* SLIntegrationTestsAppDelegate.m in Sources */, F0AC80BD16BB50FF00C5D5C0 /* SLTestsViewController.m in Sources */, @@ -1372,6 +1391,7 @@ F0AC80C416BC355D00C5D5C0 /* SLTerminalTest.m in Sources */, F0AC80C116BB559F00C5D5C0 /* SLIntegrationTest.m in Sources */, F0AC80C816BC367E00C5D5C0 /* SLTestViewController.m in Sources */, + 97AC17D718EF2B0F00B42B66 /* SLNavigationBarTests.m in Sources */, F078C04A1808BF24000767D2 /* SLWebViewTestViewController.m in Sources */, F0AC80E616BCF91800C5D5C0 /* SLTestCaseViewController.m in Sources */, 06953E3F178FDA7100B3D1B7 /* SLElementTouchAndHoldTest.m in Sources */, From 474772eda727be21702aa834d4388fed3b34a02a Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Fri, 4 Apr 2014 14:34:22 -0700 Subject: [PATCH 06/20] Cleaned up method names for table view cells --- .../Tests/SLTableViewCellChildElementsTest.m | 68 +++++++++---------- .../User Interface Elements/SLTableViewCell.h | 8 +-- .../User Interface Elements/SLTableViewCell.m | 8 +-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index 24e6c36..f10b2c8 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -149,7 +149,7 @@ - (void)testMatchingTableViewCellWithAccessibilityContainerMethod - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; + SLTableViewCell *tableViewCell = [SLTableViewCell cellWithLabel:@"Cell 2"]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); @@ -180,38 +180,38 @@ - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; } -- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex -{ - [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; - SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; - - SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); - [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; - - [UIAElement(favoriteButton) tap]; - - [self wait:1]; - [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; - [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - - [UIAElement(favoriteButton) isValidAndVisible]; - - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); - [UIAElement(favoriteButton) tap]; - - [self wait:1]; - - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); - [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; - - - [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -} +//- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex +//{ +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLTableViewCell *tableViewCell = [SLTableViewCell cellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; +// SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; +// +// SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// [UIAElement(favoriteButton) isValidAndVisible]; +// +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +//} @end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index ee771a8..1e6aa3b 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -11,11 +11,11 @@ @interface SLTableViewCell : SLAccessibilityContainer -+ (instancetype)tableViewCellWithElement:(SLElement *)element; ++ (instancetype)cellWithElement:(SLElement *)element; -+ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer; -+ (instancetype)tableViewCellWithLabel:(NSString *)label; -+ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; ++ (instancetype)cellWithIdentifier:(NSString *)identifer; ++ (instancetype)cellWithLabel:(NSString *)label; ++ (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; //+ (instancetype)tableViewCellAtIndexPath:(NSIndexPath *)indexPath; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2291fe6..2a3cf98 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -12,20 +12,20 @@ @implementation SLTableViewCell -+ (instancetype)tableViewCellWithElement:(SLElement *)element ++ (instancetype)cellWithElement:(SLElement *)element { return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer ++ (instancetype)cellWithIdentifier:(NSString *)identifer { return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithLabel:(NSString *)label ++ (instancetype)cellWithLabel:(NSString *)label { return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits ++ (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits { return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; } From 58cbd5b9485785ddc58b8b87e306d59bfcd94764 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Mon, 7 Apr 2014 12:06:19 -0700 Subject: [PATCH 07/20] Cleaned up enum for AX container types --- Integration Tests/Tests/SLNavigationBarTests.m | 4 ++-- .../Tests/SLTableViewCellChildElementsTest.m | 2 +- .../SLAccessibilityContainer.h | 10 +++++----- .../SLAccessibilityContainer.m | 12 ++++++------ .../User Interface Elements/SLTableViewCell.h | 1 + .../User Interface Elements/SLTableViewCell.m | 10 +++++----- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Integration Tests/Tests/SLNavigationBarTests.m b/Integration Tests/Tests/SLNavigationBarTests.m index 228e6a2..9850189 100644 --- a/Integration Tests/Tests/SLNavigationBarTests.m +++ b/Integration Tests/Tests/SLNavigationBarTests.m @@ -33,7 +33,7 @@ - (void)testRightButtonBroadMatching { - (void)testRightButtonWithNewMethod { - SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLAccessibilityContainerTypeNavigationBar]; SLLogAsync(@"navBar is %@", navBar); SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); SLButton *rightButton = [navBar childElementMatching:[SLButton elementWithAccessibilityLabel:@"Right"]]; @@ -45,7 +45,7 @@ - (void)testRightButtonWithNewMethod - (void)testTitleLabel { - SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLAccessibilityContainerTypeNavigationBar]; SLLogAsync(@"navBar is %@", navBar); SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); SLElement *title = [navBar childElementMatching:[SLElement elementWithAccessibilityLabel:@"Testing" value:nil traits:UIAccessibilityTraitStaticText]]; diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index f10b2c8..58851ae 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -115,7 +115,7 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView - (void)testMatchingTableViewCellWithAccessibilityContainerMethod { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; + SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLAccessibilityContainerTypeTableViewCell]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h index fde9779..82fa4d2 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -9,11 +9,11 @@ #import "SLElement.h" typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { - SLTableViewAccessibilityContainer, - SLCollectionViewAccessibilityContainer, - SLNavigationBarContainer, - SLToolbarContainer, - SLTabBarContainer + SLAccessibilityContainerTypeTableViewCell, + SLAccessibilityContainerTypeCollectionViewCell, + SLAccessibilityContainerTypeNavigationBar, + SLAccessibilityContainerTypeToolbar, + SLAccessibilityContainerTypeTabBar }; @interface SLAccessibilityContainer : SLElement diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 4f9a98f..4e915a6 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -62,19 +62,19 @@ - (id)childElementMatching:(SLElement *)childElement } Class compareClass; switch (_containerType) { - case SLTableViewAccessibilityContainer: + case SLAccessibilityContainerTypeTableViewCell: compareClass = [UITableView class]; break; - case SLCollectionViewAccessibilityContainer: + case SLAccessibilityContainerTypeCollectionViewCell: compareClass = [UICollectionView class]; break; - case SLNavigationBarContainer: + case SLAccessibilityContainerTypeNavigationBar: compareClass = [UINavigationBar class]; break; - case SLTabBarContainer: + case SLAccessibilityContainerTypeTabBar: compareClass = [UITabBar class]; break; - case SLToolbarContainer: + case SLAccessibilityContainerTypeToolbar: compareClass = [UIToolbar class]; break; @@ -82,7 +82,7 @@ - (id)childElementMatching:(SLElement *)childElement compareClass = [UIView class]; break; } - if ((_containerType == SLNavigationBarContainer) || (_containerType == SLTabBarContainer) || (_containerType == SLToolbarContainer)) { + if ((_containerType == SLAccessibilityContainerTypeTabBar) || (_containerType == SLAccessibilityContainerTypeNavigationBar) || (_containerType == SLAccessibilityContainerTypeToolbar)) { return [accessibilityParent isKindOfClass:compareClass]; } diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index 1e6aa3b..e3d6ec0 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -12,6 +12,7 @@ + (instancetype)cellWithElement:(SLElement *)element; +//+ (instancetype)cellWithElement:(SLElement *)element inTableViewWithIdentifier:(NSString *)identifier; + (instancetype)cellWithIdentifier:(NSString *)identifer; + (instancetype)cellWithLabel:(NSString *)label; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2a3cf98..1291cae 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -14,24 +14,24 @@ @implementation SLTableViewCell + (instancetype)cellWithElement:(SLElement *)element { - return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithElement:element andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithIdentifier:(NSString *)identifer { - return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithLabel:(NSString *)label { - return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithLabel:label andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits { - return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement { - return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLAccessibilityContainerTypeTableViewCell]; } //+ (id)tableViewCellAtIndexPath:(NSIndexPath *)indexPath From 0264c06ac3e13dd322068e2377ec21a1962bd766 Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Thu, 10 Apr 2014 22:18:47 -0700 Subject: [PATCH 08/20] Include collection view cell mock views in accessibility paths. (fixes #178) --- .../Tests/SLElementMatchingTest.m | 18 ++++ .../SLElementMatchingTestViewController.m | 101 +++++++++++++++--- .../NSObject+SLAccessibilityHierarchy.m | 12 +++ 3 files changed, 117 insertions(+), 14 deletions(-) diff --git a/Integration Tests/Tests/SLElementMatchingTest.m b/Integration Tests/Tests/SLElementMatchingTest.m index 68bcdde..ad34f54 100644 --- a/Integration Tests/Tests/SLElementMatchingTest.m +++ b/Integration Tests/Tests/SLElementMatchingTest.m @@ -34,6 +34,16 @@ + (NSString *)testCaseViewControllerClassName { return @"SLElementMatchingTestViewController"; } ++ (BOOL)testCaseWithSelectorSupportsCurrentPlatform:(SEL)testCaseSelector { + if (![super testCaseWithSelectorSupportsCurrentPlatform:testCaseSelector]) return NO; + + if (testCaseSelector == @selector(testMatchingCollectionViewCellChildElement)) { + return kCFCoreFoundationVersionNumber > kCFCoreFoundationVersionNumber_iOS_5_1; + } + + return YES; +} + - (void)setUpTestCaseWithSelector:(SEL)testCaseSelector { [super setUpTestCaseWithSelector:testCaseSelector]; @@ -263,6 +273,14 @@ - (void)testMatchingTableViewHeaderChildElements { SLAssertTrue([rightLabel isValid], @"Could not match UITableView header child element."); } +#pragma mark - Collection views + +- (void)testMatchingCollectionViewCellChildElement { + SLButton *fooButton = [SLButton elementWithAccessibilityLabel:@"fooButton"]; + SLAssertTrue([[UIAElement(fooButton) label] isEqualToString:@"fooButton"], + @"Could not match `UICollectionViewCell` child element."); +} + #pragma mark - Web views // This test case is restricted to the iPhone to guarantee the properties of diff --git a/Integration Tests/Tests/SLElementMatchingTestViewController.m b/Integration Tests/Tests/SLElementMatchingTestViewController.m index 0e99927..e2de5e1 100644 --- a/Integration Tests/Tests/SLElementMatchingTestViewController.m +++ b/Integration Tests/Tests/SLElementMatchingTestViewController.m @@ -29,15 +29,15 @@ @interface SLElementMatchingTestViewController : SLTestCaseViewController @end -#pragma mark - SLElementMatchingTestCell +#pragma mark - SLElementMatchingTestTableViewCell -@interface SLElementMatchingTestCell : UITableViewCell +@interface SLElementMatchingTestTableViewCell : UITableViewCell - (void)configureAccessibility; @end -@implementation SLElementMatchingTestCell { +@implementation SLElementMatchingTestTableViewCell { SEL _testCase; UISwitch *_switch; UILabel *_weatherCity, *_weatherTemp; @@ -107,15 +107,15 @@ - (void)layoutSubviews { @end -#pragma mark - SLElementMatchingTestHeader +#pragma mark - SLElementMatchingTestTableViewHeader -@interface SLElementMatchingTestHeader : UIView +@interface SLElementMatchingTestTableViewHeader : UIView - (instancetype)initWithTestCaseWithSelector:(SEL)testCase; @end -@implementation SLElementMatchingTestHeader { +@implementation SLElementMatchingTestTableViewHeader { UIView *_leftView, *_rightView; } @@ -167,9 +167,50 @@ - (void)removeRightView { @end +#pragma mark - SLElementMatchingTestCollectionViewCell + +@interface SLElementMatchingTestCollectionViewCell : UICollectionViewCell + ++ (CGSize)defaultSize; + +@end + +@implementation SLElementMatchingTestCollectionViewCell { + UIButton *_button; +} + ++ (CGSize)defaultSize { + return CGSizeMake(100.0f, 50.0f); +} + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + self.backgroundColor = [UIColor greenColor]; + + _button = [UIButton buttonWithType:UIButtonTypeCustom]; + _button.backgroundColor = [UIColor blueColor]; + [_button setTitle:@"fooButton" forState:UIControlStateNormal]; + [self.contentView addSubview:_button]; + } + return self; +} + +- (void)layoutSubviews { + [super layoutSubviews]; + + [_button sizeToFit]; + _button.center = self.center; +} + +@end + + #pragma mark - SLElementMatchingTestViewController -@interface SLElementMatchingTestViewController () +@interface SLElementMatchingTestViewController () < UITableViewDataSource, UITableViewDelegate, + UICollectionViewDataSource, UICollectionViewDelegate, + UIWebViewDelegate > // fooButton is purposely strong so that we can hold onto it // while it's removed from the view hierarchy in testElementsWaitToMatchValidObjects @@ -185,9 +226,10 @@ @interface SLElementMatchingTestViewController () kCFCoreFoundationVersionNumber_iOS_6_1; +} +@end + + @implementation UIScrollView (SLAccessibilityHierarchy) - (BOOL)classForcesPresenceInAccessibilityHierarchy { return YES; From 682f72118003802182d34493da7abd2935eb7fc4 Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Fri, 11 Apr 2014 19:19:57 -0700 Subject: [PATCH 09/20] When confirming the visibility of unknown objects, don't wait to resolve the elements. The superclass' implementation looks like: [self waitUntilTappable:NO thenPerformActionWithUIARepresentation:^(NSString *UIARepresentation) { isVisible = [[[SLTerminal sharedTerminal] evalWithFormat:@"%@.isVisible()", UIARepresentation] boolValue]; } timeout:0.0]; "Unknown objects" == objects of unknown classes like the accessibility elements vended by `UIWebBrowserView`. We shouldn't wait to resolve the element because `-isVisible` is supposed to evaluate the current state. --- .../Classes/UIAutomation/User Interface Elements/SLElement.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m index d7a321b..008e1cd 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m @@ -333,7 +333,7 @@ - (BOOL)isVisible { } timeout:0.0]; if (isVisible && matchedObjectOfUnknownClass) { - isVisible = [[self waitUntilTappable:NO thenSendMessage:@"isVisible()"] boolValue]; + isVisible = [super isVisible]; } return isVisible; From 2fb53345589a7924284ac4647d6137a0ba20d9c8 Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Fri, 11 Apr 2014 19:51:38 -0700 Subject: [PATCH 10/20] Temporarily use UIAutomation to check visibility in non-portrait orientations. (refs #135) As a workaround for the failure of our visibility routine. --- .../Tests/SLElementVisibilityTest.m | 36 +++++++++++++++++++ .../SLElementVisibilityTestViewController.m | 5 +++ .../User Interface Elements/SLElement.m | 6 ++++ 3 files changed, 47 insertions(+) diff --git a/Integration Tests/Tests/SLElementVisibilityTest.m b/Integration Tests/Tests/SLElementVisibilityTest.m index cebb45c..95d2764 100644 --- a/Integration Tests/Tests/SLElementVisibilityTest.m +++ b/Integration Tests/Tests/SLElementVisibilityTest.m @@ -80,9 +80,25 @@ - (void)setUpTestCaseWithSelector:(SEL)testSelector { if (testSelector == @selector(testCanDetermineVisibilityOfWebAccessibilityElements)) { SLAssertTrueWithTimeout(SLAskAppYesNo(webViewDidFinishLoad), 5.0, @"Webview did not load test HTML."); + } else if ((testSelector == @selector(testViewIsVisibleInPortrait)) || + (testSelector == @selector(testViewIsVisibleInPortraitUpsideDown)) || + (testSelector == @selector(testViewIsVisibleInLandscapeLeft)) || + (testSelector == @selector(testViewIsVisibleInLandscapeRight))) { + SLAskApp(showTestView); } } +- (void)tearDownTestCaseWithSelector:(SEL)testCaseSelector { + if ((testCaseSelector == @selector(testViewIsVisibleInPortrait)) || + (testCaseSelector == @selector(testViewIsVisibleInPortraitUpsideDown)) || + (testCaseSelector == @selector(testViewIsVisibleInLandscapeLeft)) || + (testCaseSelector == @selector(testViewIsVisibleInLandscapeRight))) { + [[SLDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]; + } + + [super tearDownTestCaseWithSelector:testCaseSelector]; +} + #pragma mark - Test isVisible for elements that are views - (void)testViewIsNotVisibleIfItIsHidden { @@ -225,6 +241,26 @@ - (void)testViewIsVisibleIfItsCenterIsCoveredByClearRegion { SLAssertTrue([_testElement isVisible], @"Subliminal should say that the element is visible."); } +- (void)testViewIsVisibleInPortrait { + [[SLDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]; + SLAssertTrue([UIAElement(_testElement) isVisible], @"Button should be visible"); +} + +- (void)testViewIsVisibleInPortraitUpsideDown { + [[SLDevice currentDevice] setOrientation:UIDeviceOrientationPortraitUpsideDown]; + SLAssertTrue([UIAElement(_testElement) isVisible], @"Button should be visible"); +} + +- (void)testViewIsVisibleInLandscapeLeft { + [[SLDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; + SLAssertTrue([UIAElement(_testElement) isVisible], @"Button should be visible"); +} + +- (void)testViewIsVisibleInLandscapeRight { + [[SLDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeRight]; + SLAssertTrue([UIAElement(_testElement) isVisible], @"Button should be visible"); +} + #pragma mark - Test isVisible for elements that are not views - (void)testAccessibilityElementIsNotVisibleIfContainerIsHidden { diff --git a/Integration Tests/Tests/SLElementVisibilityTestViewController.m b/Integration Tests/Tests/SLElementVisibilityTestViewController.m index a702ef6..c96d203 100644 --- a/Integration Tests/Tests/SLElementVisibilityTestViewController.m +++ b/Integration Tests/Tests/SLElementVisibilityTestViewController.m @@ -226,6 +226,11 @@ + (NSString *)nibNameForTestCase:(SEL)testCase { (testCase == @selector(testIsInvalidOrInvisibleDoesNotThrowIfElementIsInvalid)) || (testCase == @selector(testIsInvalidOrInvisibleReturnsYESIfElementIsInvalidOrInvisible))) { nibName = @"SLElementVisibilityTestHidden"; + } else if ((testCase == @selector(testViewIsVisibleInPortrait)) || + (testCase == @selector(testViewIsVisibleInPortraitUpsideDown)) || + (testCase == @selector(testViewIsVisibleInLandscapeLeft)) || + (testCase == @selector(testViewIsVisibleInLandscapeRight))) { + nibName = @"SLElementVisibilityTestHidden"; } return nibName; } diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m index 008e1cd..9e8a896 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m @@ -324,6 +324,12 @@ - (BOOL)isValid { they will be visible, and must depend on UIAutomation to confirm visibility. */ - (BOOL)isVisible { + // Temporarily use UIAutomation to check visibility if the device is in a non-portrait orientation + // to work around https://github.com/inkling/Subliminal/issues/135 + if ([UIDevice currentDevice].orientation != UIDeviceOrientationPortrait) { + return [super isVisible]; + } + __block BOOL isVisible = NO; __block BOOL matchedObjectOfUnknownClass = NO; // isVisible evaluates the current state, no waiting to resolve the element From 0e115936a185683c9a89e1fae6dbd58e6e4c276b Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Fri, 11 Apr 2014 21:27:40 -0700 Subject: [PATCH 11/20] Ensure that `-[SLDevice setOrientation:]` waits for the device to rotate. The previous delay was not long enough for the animation to complete on the iPad. --- Sources/Classes/UIAutomation/SLDevice.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Classes/UIAutomation/SLDevice.m b/Sources/Classes/UIAutomation/SLDevice.m index 56b8a05..318a517 100644 --- a/Sources/Classes/UIAutomation/SLDevice.m +++ b/Sources/Classes/UIAutomation/SLDevice.m @@ -60,8 +60,8 @@ - (void)deactivateAppForDuration:(NSTimeInterval)duration { - (void)setOrientation:(UIDeviceOrientation)deviceOrientation { [[SLTerminal sharedTerminal] evalWithFormat:@"UIATarget.localTarget().setDeviceOrientation(%@)", SLUIADeviceOrientationFromUIDeviceOrientation(deviceOrientation)]; - // Delay slightly to ensure that UIDevice registers the new orientation - [NSThread sleepForTimeInterval:0.3]; + // Delay to ensure that the rotation completes and UIDevice registers the new orientation + [NSThread sleepForTimeInterval:1.0]; } #pragma mark - Screenshots From 5829bde1ec16305b641a421f77d1df08c17a5977 Mon Sep 17 00:00:00 2001 From: Jeff Wear Date: Sun, 20 Apr 2014 02:31:35 -0700 Subject: [PATCH 12/20] Reset the device orientation after deactivation on iPads running iOS 5.1 or 7.1. (refs #180) On iPads running iOS 5.1 or 7.1, `UIDevice` forgets its orientation after deactivation. This is not only unexpected but can mess with `-[SLElement isVisible]` which (as of #180) falls back upon `UIAutomation`'s visibility routine if (but only if) the device is in a non-portrait orientation. --- Integration Tests/Tests/SLDeviceTest.m | 8 ++++++++ Sources/Classes/UIAutomation/SLDevice.m | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/Integration Tests/Tests/SLDeviceTest.m b/Integration Tests/Tests/SLDeviceTest.m index ee599a9..666b48f 100644 --- a/Integration Tests/Tests/SLDeviceTest.m +++ b/Integration Tests/Tests/SLDeviceTest.m @@ -90,6 +90,14 @@ - (void)testCanRotateDevice } } +// Exercises a bug in iOS 5.1 and 7.1. See https://github.com/inkling/Subliminal/pull/180#issuecomment-40891098 +- (void)testThatDeviceOrientationPersistsThroughDeactivation { + UIDeviceOrientation currentOrientation = [UIDevice currentDevice].orientation; + [[SLDevice currentDevice] deactivateAppForDuration:3.0]; + SLAssertTrue([UIDevice currentDevice].orientation == currentOrientation, + @"The device orientation should not have changed."); +} + - (void)rotateToAndCheckOrientation:(UIDeviceOrientation)orientation { [[SLDevice currentDevice] setOrientation:orientation]; diff --git a/Sources/Classes/UIAutomation/SLDevice.m b/Sources/Classes/UIAutomation/SLDevice.m index 318a517..9329506 100644 --- a/Sources/Classes/UIAutomation/SLDevice.m +++ b/Sources/Classes/UIAutomation/SLDevice.m @@ -39,7 +39,18 @@ + (SLDevice *)currentDevice { } - (void)deactivateAppForDuration:(NSTimeInterval)duration { + UIDeviceOrientation currentOrientation = [UIDevice currentDevice].orientation; + [[SLTerminal sharedTerminal] evalWithFormat:@"UIATarget.localTarget().deactivateAppForDuration(%g)", duration]; + + // On iPads running iOS 5.1 and 7.1, `UIDevice` forgets its orientation after deactivation. + // This is not only unexpected but can mess with `-[SLElement isVisible]`. + // See https://github.com/inkling/Subliminal/pull/180#issuecomment-40891098 + if (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) && + ((kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_6_0) || + (kCFCoreFoundationVersionNumber > kCFCoreFoundationVersionNumber_iOS_6_1))) { + [self setOrientation:currentOrientation]; + } } #pragma mark - Device Rotation From b836640c908ab7c1518e0fa029145b24471218fb Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 16:05:47 -0700 Subject: [PATCH 13/20] Initial commit with SLAccessibilityContainer and working tests --- .../Tests/SLTableViewCellChildElementsTest.m | 598 ++++++++++++++++++ ...eViewCellChildElementsTestViewController.m | 155 +++++ ...iewCellChildElementsTestViewController.xib | 34 + .../Tests/heart_empty_icon&32.png | Bin 0 -> 3855 bytes Integration Tests/Tests/heart_icon&32.png | Bin 0 -> 3510 bytes .../Classes/Internal/NSObject+SLVisibility.m | 7 +- .../SLAccessibilityContainer.h | 32 + .../SLAccessibilityContainer.m | 100 +++ Sources/Subliminal.h | 1 + Subliminal.xcodeproj/project.pbxproj | 36 ++ 10 files changed, 962 insertions(+), 1 deletion(-) create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTest.m create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m create mode 100644 Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib create mode 100755 Integration Tests/Tests/heart_empty_icon&32.png create mode 100755 Integration Tests/Tests/heart_icon&32.png create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m new file mode 100644 index 0000000..5bd24fa --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -0,0 +1,598 @@ +// +// SLTableViewCellChildElementsTest.m +// Subliminal +// +// Created by Jordan Zucker on 3/20/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLIntegrationTest.h" + +@interface focus_SLTableViewCellChildElementsTest : SLIntegrationTest + +@end + +@implementation focus_SLTableViewCellChildElementsTest + ++ (NSString *)testCaseViewControllerClassName { + return @"SLTableViewCellChildElementsTestViewController"; +} + +// If you override set-up methods, +// you must call super at the beginning of your implementations. + +// If you override tear-down methods, +// you must call super at the *end* of your implementations. + +- (void)testTapBroadMatchingTableViewCellButton { + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + + SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; +// SLLogAsync(@"favoritButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton recursive is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +} + +//- (void)testOriginalHackMatchingTableViewCell +//{ +//// [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { +// +// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { +// +// id accessibilityParent = [obj slAccessibilityParent]; +// +// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); +// while (accessibilityParent && ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"]) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); +// +// } +// +// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); +// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; +// +// } +// +// return NO; +// +// } withDescription:@"searching for favoritebutton"]; +// +//// SLLogAsync(@"favoriteButton is %@", favoriteButton); +//// +//// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [favoriteButton isValidAndVisible]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +//// SLLogAsync(@"testing"); +//// SLLogAsync(@"favoriteButton is %@", favoriteButton); +//// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +//// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +//// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +//// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +// +// +//} + +//- (void)testOriginalHackMatchingTableViewCellWithNoAXMatching +//{ +//// [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { +// +// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { +// +// id accessibilityParent = [obj slAccessibilityParent]; +// +// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); +// while (accessibilityParent && (![accessibilityParent isKindOfClass:[UITableViewCell class]] || ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"])) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); +// +// } +// +// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); +// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; +// +// } +// +// return NO; +// +// } withDescription:@"searching for favoritebutton"]; +// +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// +// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// //SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; +// +// +//} + +- (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView +{ +// [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { + + if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { + + id accessibilityParent = [obj slAccessibilityParent]; + + //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); + while (accessibilityParent && ![[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]) { + + accessibilityParent = [accessibilityParent slAccessibilityParent]; + //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); + + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; + + while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:[UITableView class]]) { + doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; + } + + if (doubleAccessibilityParent) { + return YES; + } + else { + return NO; + } + + + } + + return NO; + + } withDescription:@"searching for favoritebutton"]; + +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// +// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + +// SLLogAsync(@"testing"); +// SLLogAsync(@"favoriteButton is %@", favoriteButton); +// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// SLLogAsync(@"now log element tree for favorite button"); +// [favoriteButton logElementTree]; + + +} + +- (void)testMatchingTableViewCellWithNewMethod +{ + // [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// cell2.parentElementType = SLTableViewCellElement; +// //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; + SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // + // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); + // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); + // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + + // SLLogAsync(@"testing"); + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); + // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); + // SLLogAsync(@"now log element tree for favorite button"); + // [favoriteButton logElementTree]; + + +} + + +//- (void)testMatchingTableViewCellWithNewMethod +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodTVCSubclass +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; +// SLTableViewCell *cell2 = [SLTableViewCell parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; +// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; +// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + + +//- (void)testMatchingTableViewCellWithNewMethod +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:UIAccessibilityTraitButton inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodAnyTraits +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + +//- (void)testMatchingTableViewCellWithNewMethodAnyTraitsAndElement +//{ +// // [[SLWindow mainWindow] logElementTree]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLElement *favoriteButton = [SLElement elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; +// +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // +// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); +// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); +// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +// +// +// // SLLogAsync(@"testing"); +// // SLLogAsync(@"favoriteButton is %@", favoriteButton); +// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); +// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); +// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); +// // SLLogAsync(@"now log element tree for favorite button"); +// // [favoriteButton logElementTree]; +// +// +//} + + +@end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m new file mode 100644 index 0000000..25d0f08 --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m @@ -0,0 +1,155 @@ +// +// SLTableViewCellChildElementsTestViewController.m +// Subliminal +// +// Created by Jordan Zucker on 3/20/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTestCaseViewController.h" + +#import + +@interface SLTableViewCellChildElementsTestViewController : SLTestCaseViewController + +@end + +@interface SLTableViewCellChildElementsTestViewController () +@property (nonatomic, weak) IBOutlet UITableView *tableView; +@property (nonatomic, strong) NSArray *tableViewElements; +@property (nonatomic, strong) NSMutableArray *tableViewFavorites; +@end + +@implementation SLTableViewCellChildElementsTestViewController + ++ (NSString *)nibNameForTestCase:(SEL)testCase { + return @"SLTableViewCellChildElementsTestViewController"; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + _tableViewElements = @[@"Cell 0", @"Cell 1", @"Cell 2", @"Cell 3"]; + _tableViewFavorites = [[NSMutableArray alloc] initWithObjects:@(NO), @(NO), @(NO), @(NO), nil]; + + // Do any additional setup after loading the view from its nib. + // Test case specific configuration is best done using app hooks + // triggered from -[SLTableViewCellChildElementsTests setUpTestCaseWithSelector:]. +} + +- (instancetype)initWithTestCaseWithSelector:(SEL)testCase { + self = [super initWithTestCaseWithSelector:testCase]; + if (self) { + // Register for app hooks, e.g. + // [[SLTestController sharedTestController] registerTarget:<#(id)#> forAction:<#(SEL)#>]; + } + return self; +} + +// Deregister for app hooks, if any +//- (void)dealloc { +// [[SLTestController sharedTestController] deregisterTarget:self]; +//} + +//#pragma mark - App hooks +// Put any app hooks below here + +#pragma mark - UIButton method + +- (IBAction)pressButton:(id)sender +{ + UIButton *favoriteButton = (UIButton *)sender; + NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + [self setFavoriteButton:favoriteButton withFavoriteStatus:(![oldFavoriteBool boolValue])]; + // NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + // NSNumber *updatedFavoriteBool; + // NSString *updatedFavoriteButtonAccessibilityValue; + // UIImage *updatedFavoriteButtonImage; + // if ([oldFavoriteBool boolValue] == YES) { + // updatedFavoriteBool = @(NO); + // updatedFavoriteButtonAccessibilityValue = @"off"; + // updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_empty_icon&32.png"]; + // + // } + // else { + // updatedFavoriteBool = @(YES); + // updatedFavoriteButtonAccessibilityValue = @"on"; + // updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_icon&32.png"]; + // } + // [_tableViewFavorites setObject:updatedFavoriteBool atIndexedSubscript:favoriteButton.tag]; + // favoriteButton.accessibilityValue = updatedFavoriteButtonAccessibilityValue; + // [favoriteButton setImage:updatedFavoriteButtonImage forState:UIControlStateNormal]; + + // if ([favoriteButton.titleLabel.text isEqualToString:@"Favorite"]) { + // [favoriteButton setTitle:@"Unfavorite" forState:UIControlStateNormal]; + // } + // else { + // [favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; + // } + //[favoriteButton setImage:[UIImage imageNamed:@"heart_icon&32.png"] forState:UIControlStateNormal]; +} + +- (void) setFavoriteButton:(UIButton *)favoriteButton withFavoriteStatus:(BOOL)favoriteBool +{ + //NSNumber *oldFavoriteBool = [_tableViewFavorites objectAtIndex:favoriteButton.tag]; + // NSNumber *updatedFavoriteBool; + NSString *updatedFavoriteButtonAccessibilityValue; + UIImage *updatedFavoriteButtonImage; + if (favoriteBool == YES) { + // updatedFavoriteBool = @(NO); + updatedFavoriteButtonAccessibilityValue = @"on"; + updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_icon&32.png"]; + + } + else { + // updatedFavoriteBool = @(YES); + updatedFavoriteButtonAccessibilityValue = @"off"; + updatedFavoriteButtonImage = [UIImage imageNamed:@"heart_empty_icon&32.png"]; + } + [_tableViewFavorites setObject:@(favoriteBool) atIndexedSubscript:favoriteButton.tag]; + favoriteButton.accessibilityValue = updatedFavoriteButtonAccessibilityValue; + [favoriteButton setImage:updatedFavoriteButtonImage forState:UIControlStateNormal]; +} + +#pragma mark - UITableViewDataSource + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [_tableViewElements count]; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + } + + cell.textLabel.text = [_tableViewElements objectAtIndex:indexPath.row]; + + //UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + //[favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; + UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; + //[favoriteButton setImage:[UIImage imageNamed:@"heart_empty_icon&32.png"] forState:UIControlStateNormal]; + favoriteButton.accessibilityLabel = @"Favorite"; + //favoriteButton.accessibilityValue = @"off"; + favoriteButton.tag = indexPath.row; + + favoriteButton.frame = CGRectMake(160.0f, 5.0f, 32.0f, 32.0f); + [self setFavoriteButton:favoriteButton withFavoriteStatus:[[_tableViewFavorites objectAtIndex:indexPath.row] boolValue]]; + [favoriteButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside]; + [cell addSubview:favoriteButton]; + + cell.accessibilityLabel = cell.textLabel.text; + cell.accessibilityValue = cell.textLabel.text; + + return cell; +} + +@end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib new file mode 100644 index 0000000..4483677 --- /dev/null +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.xib @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Integration Tests/Tests/heart_empty_icon&32.png b/Integration Tests/Tests/heart_empty_icon&32.png new file mode 100755 index 0000000000000000000000000000000000000000..9c324dcae4870583d1e9e693c693dac84baa343d GIT binary patch literal 3855 zcmb_f4Ommx8IIyFYO7PH_UYPdbZU#qO#%^emw@?UfRf-yG)$-Ea_>oUCAl}=djkQt zYK4j-N}YCnioflAWctkN{1-(KEZ9-4RUdVAFhw2y%QH80t<#-*^J7A(U46y_fpgCH zz2AG@?>pZ)ET3UX8xs3UtVALil96u8hQATvXFxyr$rTs>QzD7&N7-`t9CIc{FdjKh zGI>Dm_juvDM50acdvPKk@JJqTQnXHb|8SiYp-7$7t~M*oUL$Z(>BTIt7F%pYaXz6T zr76j=T0aH>Jb=d$zsF5;m|rIqaWVL}FpWwP(S*;}N%cZNB*#1hF)}Pb)N+N4P)t!E zQrX z78c42s*Ui{$e!jWK6UB<-QwyN3!5sA{AZIJ`0yGkDG8Fss;;3DN`tADz!}+kEzv|QW>XE!tx2(o6T4T&G9%*fDDsP z3c=+RMPeFbyjq{APD)a#l2RdtCP`y7D)dUdNue^Rjj9ND6GQlf1cuznALgC~D}|zQ z_Y1)Yg^OsPDKeA8oxlcI4=1h!idygH1EavuO$n8ZxpCSF_bVfT1NXUkX|j<8I8PM- zcnUophUO4G&$CpXPdE%R3quRjfF&s0jkqZS&>YaB!WnT>!C2xb6ih3WRWMK8SZPTD zBZOcK8^O{F7DTg5PJ^PlAv*#fgpcDH55hByI}c|OiV*mbfTNsrPb5NETC`gzAvAOg zo$-k9A>P48@LeL=DHb?b+yf9O5fe?QCnh0SkxBQ+0vpbkHy;qe1c`mjfIGVh5!}77 z>mD~9%4>3zKGAf-HW6UlcbHH#4_Hz6o+J(<`Kaf!aekixk8}CqbVhRtj6za~>P0Fg zC>Q9kKRkv1?>djBqK)jym>7#;jSReM2tI>$Fyc)TZ9~mu-FAkBH(|t`x(^qz7!5&saW7fsH+#f?b0x`X2-m?;{MR2=+Ril*0=EDRy|+T?0$hi{24o zghCg9(9ge*!p4LPc4y&gLxsnZaGeD!;9IHr)=mStGetGIz#M!a!Iv2tewx8S_;Ckl z7>tEax6x_VMex}-hEL7mt&D>[H-ywJp=%LX`EwBR$K72bw|kv`LA!<`bFi{cRY z&AWiuo)HHN8}_pnE>tm`1A$cz;Q%j3F6Q4j4slEZPB@K{=N(W4UPQ8po5;c-Ccsh! z;?2b^Y~8gP;-w1D*$4&Tl;p(-9vSxN73iBT06rrqz`Z!hoFy%NC6buD43pmG|LTbS zq~+4oq5C&1e$bpRcnY9ec+l)n6@=X@^a|esaaw^GpfpYTA_TSbIjd?$%%;{bp4~Fx}mLY z-mKz;l$0-C{a{_`CG#NuC-2HVTT(};`n~nq>WSIEb0L6i-%0+wM++0#pB0F*Y*O=z$ zpkMgwN_XU}-FR;9;F@^@t)G^amEGR6XV1V>m8({rZ@f`ID`tOke7x1((A?Zyb6)@3 zuE8I+__Z7FtX+^h=gd4~tl?MH_a|JOU+)-(J!x2cy6h!v*ZA_&c&E=Yu()` zmdxDh)Yxei^;@J-3{gg?bTbi`fF#mPumC0;_fPvH5#hjziCW!sSIl}P_T)Sr5P!_M|qliDxJ>rSwz z3d{FcTBlw$kGmZ6a(U^TFWU}opFiUexBio@X-T#RU!FbN*tzuI9S>&5UH<&)Rifpa zas0!xt*xG7&HmZT&bV&fyt!@rzI8P0Z$Jr6fO|$CN$Kt+vI=)fi j|9jSn^>w2k!KoIgI_iv1#0M%?t&dS0Q9<3iJVyD z{%^nk-+%XxriMkcatm__f|%v2^ETuE!1z7;Ec{oG$Bz?4?pZ>h6}9^78BUR`EU&af zYfMt{Izc$Eh^Z{s0TF12AwhPL-#xdF1Oo3OTgv@5zv_Wup)Rh$CGmy;7w_O4Jb6V` zt~17900|-%#3WJHnV5?-aT)yGn5IZznxGCB={5p_R(})lC>jLiR-1*hU1kH9(N?;& ztfHc#1lVn~jk4J(+HRpMm{L1qvw`FfS(OW%8Xshuy;mlK;gO3BBcw7E6^%x%(Ne3T zg(%wLa2OzVy9HZV^e!2(F^jBUU_c}=yin&fK}CWh0|S$7S0czol6W1Yb|R_GLMV*% zbO>2bYKGOLVysHhRvV?6HdLl3&!t_|h$fnxc#eW1l%R}s>_%tV`&7i0VHpio(w>+c zXL{<0r!pSe*eVg zl9a_tN41?;*JO^y6;Ka!sgP=hx)RYiSlfvuy1)#IsU;G?_*tz3;z|r?5tv$H{J6S! z7O`FyVbyTq&=wnQv6lzvQl`9|q3L29jmsxx@Aor4Sx2nQL7&$}VsNV<@JwZ`*XyV( zudKA&D{C=^qtfB=*xa<+YqQssd+ZtRUWJPo2~4^3|INJ-SBfCB;-p}V!UfLLiY(RH z5DY*~(#@4bQM*Ny7$t_HU{o?AvT_LT*TTaf8xav%<OP%qI@G0KOM(}qcwFnvv zYODkSmPpAaG#--_tjT0-WP^NeHqIQ`HX^hHn!ec##Qnuq{NM$1=XyM+2 z8+)CAyN1^FF9b60BL=4k_c|A;vz?GPJ3Q{Li6vpOcSIT?8ip8p;`=CV%!P4xHm)|x zcq|#$S+WBDlA6ElG?6=RR+CH2;Rh0anNjJd86Kn`cTmQ`H2ie?>A5vE_}N#0YFp6~ zC5WP|28qNA%`CcR$nssw4nn8#HZ+Xf^??8zA_8GS2l#`+&}`2jsNsfvx`i86jOSot zRR=mmR`71e$RNh?8aU}R5)&OzfG;9T#!b|q058;pPV?r{mmk^LkMU}a=WK=oc#4=D z!RKe6D8#;X2HbyCP zZ4Lb{_u=zKrr)_R>~fFpxP18;`jpb6IbXd-_H4f7=!?hqmOb#u8-sz;Qy)9#+*9%6 zvE@JB^x1)&L!WC!y`jFsp=Fy-ZDjN3_C9_6<3BGxpLjNsUsT=5yuN<__c?E#d1T-z13m#g$k>!PlF zX=us5kCZL-t%8X*ryuN!E39(DosRaj0%fPCcc@N~}|N6%eact(vY4h8v*5rTFxH@O$ zKu+PB;m=ild}Ifu6wlnlAIK*?FOe($Yq z+v{ibRew7r@X^b1(fj_Zx4+d=GVjwVZ3B+A^&c)+UgKppzObeE$uH5PqZg4|FW#R! z+|lA2?fq`m2cH~=m)?I*ciFlfvqrnCwr-kPec`>n>F@68on5*I9cq7~|L*xeYzUI8 zPZZBNc5uz`MXrL`a`E7&%l6ejxbXIo%^}a5!;9Yt&s{rmol3tt18cmkqv8AbhPn&M zYrj>u7wp-#>pd~pa?Vk;vLv^szbAj8_a#N%wAeGyv|zBZFW$fVzAw5?E;@NfkG}8g b?in`XsyI0K^O1F1jk5C9Hh6c`wDtT6rTv@G literal 0 HcmV?d00001 diff --git a/Sources/Classes/Internal/NSObject+SLVisibility.m b/Sources/Classes/Internal/NSObject+SLVisibility.m index 08ee502..199d6ff 100644 --- a/Sources/Classes/Internal/NSObject+SLVisibility.m +++ b/Sources/Classes/Internal/NSObject+SLVisibility.m @@ -133,7 +133,12 @@ - (BOOL)slAccessibilityIsVisible { // if another element comes before us/our parent in the array // (thus is z-ordered before us/our parent) // and contains our hitpoint, it covers us - if (CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; +// SLLogAsync(@"element is %@", [element description]); +// SLLogAsync(@"element is %@", element); +// SLLogAsync(@"element frame is %@", NSStringFromCGRect([element accessibilityFrame])); +// SLLogAsync(@"testPoint is %@", NSStringFromCGPoint(testPoint)); +// SLLogAsync(@"container frame is %@", NSStringFromCGRect([container accessibilityFrame])); + if (![NSStringFromClass([element class]) isEqualToString:@"UITableTextAccessibilityElement"] && CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; } // we should eventually reach a container that is a view diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h new file mode 100644 index 0000000..902fb36 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -0,0 +1,32 @@ +// +// SLAccessibilityContainer.h +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLElement.h" + +typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { + SLTableViewAccessibilityContainer, + SLCollectionViewAccessibilityContainer +}; + +@interface SLAccessibilityContainer : SLElement + +@property (nonatomic) SLElement *containerElement; +@property (nonatomic, assign) SLAccessibilityContainerType containerType; + +- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + ++ (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + ++ (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; ++ (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; ++ (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + +- (id)childElementMatching:(SLElement *)childElement; ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement ofContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + +@end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m new file mode 100644 index 0000000..0fa5525 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -0,0 +1,100 @@ +// +// SLAccessibilityContainer.m +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLAccessibilityContainer.h" +#import "SLUIAElement+Subclassing.h" +#import "NSObject+SLAccessibilityHierarchy.h" + +@implementation SLAccessibilityContainer + +- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + self = [super init]; + if (self) { + _containerElement = element; + _containerType = accessibilityContainerType; + } + return self; +} + ++ (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:element andContainerType:accessibilityContainerType]; +} + ++ (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityIdentifier:identifer] andContainerType:accessibilityContainerType]; +} ++ (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label] andContainerType:accessibilityContainerType]; +} ++ (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label value:value traits:traits] andContainerType:accessibilityContainerType]; +} + +- (id)childElementMatching:(SLElement *)childElement +{ + return [SLElement elementMatching:^BOOL(NSObject *obj) { + // first match child element + if ([childElement matchesObject:obj]) { + + id accessibilityParent = [obj slAccessibilityParent]; + + //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); + // then look for child element having matching parent + while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { + + accessibilityParent = [accessibilityParent slAccessibilityParent]; + //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); + + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; + + Class compareClass; + switch (_containerType) { + case SLTableViewAccessibilityContainer: + compareClass = [UITableView class]; + break; + case SLCollectionViewAccessibilityContainer: + compareClass = [UICollectionView class]; + break; + + default: + compareClass = [UIView class]; + break; + } + + while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:compareClass]) { + doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; + } + + if (doubleAccessibilityParent) { + return YES; + } + else { + return NO; + } + + + } + + return NO; + } withDescription:@"searching for child element"]; +} ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement ofContainerType:(SLAccessibilityContainerType)accessibilityContainerType +{ + SLAccessibilityContainer *container = [SLAccessibilityContainer containerWithElement:containerElement andContainerType:accessibilityContainerType]; + return [container childElementMatching:childElement]; +} + +@end diff --git a/Sources/Subliminal.h b/Sources/Subliminal.h index 2942072..8c93fc6 100644 --- a/Sources/Subliminal.h +++ b/Sources/Subliminal.h @@ -28,6 +28,7 @@ #import "SLElement.h" #import "NSObject+SLAccessibilityDescription.h" #import "NSObject+SLAccessibilityHierarchy.h" +#import "SLAccessibilityContainer.h" #import "SLStaticElement.h" #import "SLAlert.h" #import "SLButton.h" diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index d291a12..ea8867e 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -41,6 +41,13 @@ 50F2B7C818E9C0D700F21635 /* SLDispatchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F2B7C718E9C0D700F21635 /* SLDispatchTests.m */; }; 50F3E18C1783A5CB00C6BD1B /* SLGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F3E18A1783A5CB00C6BD1B /* SLGeometry.h */; }; 50F3E18E1783A60100C6BD1B /* SLGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = 50F3E18B1783A5CB00C6BD1B /* SLGeometry.m */; }; + 97068F8C18ECB5AF005FE660 /* heart_empty_icon&32.png in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */; }; + 97068F8D18ECB5AF005FE660 /* heart_icon&32.png in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8818ECB5AF005FE660 /* heart_icon&32.png */; }; + 97068F8E18ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */; }; + 97068F8F18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */; }; + 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; + 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -274,6 +281,13 @@ 50F2B7C718E9C0D700F21635 /* SLDispatchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDispatchTests.m; sourceTree = ""; }; 50F3E18A1783A5CB00C6BD1B /* SLGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLGeometry.h; sourceTree = ""; }; 50F3E18B1783A5CB00C6BD1B /* SLGeometry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLGeometry.m; sourceTree = ""; }; + 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heart_empty_icon&32.png"; sourceTree = ""; }; + 97068F8818ECB5AF005FE660 /* heart_icon&32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heart_icon&32.png"; sourceTree = ""; }; + 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCellChildElementsTest.m; sourceTree = ""; }; + 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCellChildElementsTestViewController.m; sourceTree = ""; }; + 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLTableViewCellChildElementsTestViewController.xib; sourceTree = ""; }; + 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAccessibilityContainer.h; sourceTree = ""; }; + 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -518,6 +532,18 @@ name = "SLGeometry Tests"; sourceTree = ""; }; + 97068F9418ECB5B2005FE660 /* SLTableViewCellChildElements Tests */ = { + isa = PBXGroup; + children = ( + 97068F8718ECB5AF005FE660 /* heart_empty_icon&32.png */, + 97068F8818ECB5AF005FE660 /* heart_icon&32.png */, + 97068F8918ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m */, + 97068F8A18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m */, + 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */, + ); + name = "SLTableViewCellChildElements Tests"; + sourceTree = ""; + }; CAC388011641CD4800F995F9 /* Internal */ = { isa = PBXGroup; children = ( @@ -772,6 +798,8 @@ F0695DD8160138DF000B05D0 /* SLUIAElement.m */, F0A04E1B1749F70F002C7520 /* SLElement.h */, F0A04E1C1749F70F002C7520 /* SLElement.m */, + 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */, + 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */, F043469D175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.h */, F043469E175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.m */, CAC3883D1643503C00F995F9 /* NSObject+SLAccessibilityHierarchy.h */, @@ -896,6 +924,7 @@ F0AC80BE16BB542400C5D5C0 /* Tests */ = { isa = PBXGroup; children = ( + 97068F9418ECB5B2005FE660 /* SLTableViewCellChildElements Tests */, DB2627D817B96704009DA3A6 /* SLStatusBar Tests */, 50A59BD317848CEE002A863A /* SLGeometry Tests */, F07DA31F16E439B7004C2282 /* SLAlert Tests */, @@ -1008,6 +1037,7 @@ F0695E1E16014491000B05D0 /* SLTest.h in Headers */, F0695E1F16014491000B05D0 /* SLTerminal.h in Headers */, F0695E2016014491000B05D0 /* SLUIAElement.h in Headers */, + 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */, F0695E2116014491000B05D0 /* SLLogger.h in Headers */, F0271AFF162E0B950098F5F2 /* SLTestController+AppHooks.h in Headers */, CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */, @@ -1218,10 +1248,13 @@ F043A9C7172A160600A4FD1D /* SLElementVisibilityTest.html in Resources */, F08005591730762C00198F6F /* Inklings~iPhone.webarchive in Resources */, F0C4DB4817388ACA00111149 /* SLElementVisibilityTestSuperviewWithVisibleSubview.xib in Resources */, + 97068F8C18ECB5AF005FE660 /* heart_empty_icon&32.png in Resources */, 064B6F55173B13E9004AB1BF /* SLElementVisibilityTestCoveredByClearRegion.xib in Resources */, + 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */, 064B6FC7173DCE9A004AB1BF /* SLElementVisibilityWithSubviews.xib in Resources */, F0C27CDF1741694900335A41 /* SLElementStateTestMidpointCovered.xib in Resources */, F0C27CE917416EC400335A41 /* SLElementStateTestCompletelyCovered.xib in Resources */, + 97068F8D18ECB5AF005FE660 /* heart_icon&32.png in Resources */, F00800C9174B3349001927AC /* SLButtonTestViewController.xib in Resources */, F00F3B5E1778E05100119580 /* SLElementTapTestScrollViewCases.xib in Resources */, F00F3B6717790B4C00119580 /* SLStaticElementTestScrollView.xib in Resources */, @@ -1305,6 +1338,7 @@ F0C07A501704009E00C93F93 /* SLWindow.m in Sources */, F0C07A541704011400C93F93 /* SLKeyboard.m in Sources */, F0C07A58170401E500C93F93 /* SLWebView.m in Sources */, + 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */, F05C4F91171406EF00A381BC /* SLTerminal+ConvenienceFunctions.m in Sources */, F05C51E6171C8AE000A381BC /* SLMainThreadRef.m in Sources */, F0A04E1E1749F70F002C7520 /* SLElement.m in Sources */, @@ -1326,6 +1360,7 @@ F0AC80A016BB299500C5D5C0 /* main.m in Sources */, F0AC80A416BB299500C5D5C0 /* SLIntegrationTestsAppDelegate.m in Sources */, F0AC80BD16BB50FF00C5D5C0 /* SLTestsViewController.m in Sources */, + 97068F8E18ECB5AF005FE660 /* SLTableViewCellChildElementsTest.m in Sources */, F0AC80C416BC355D00C5D5C0 /* SLTerminalTest.m in Sources */, F0AC80C116BB559F00C5D5C0 /* SLIntegrationTest.m in Sources */, F0AC80C816BC367E00C5D5C0 /* SLTestViewController.m in Sources */, @@ -1366,6 +1401,7 @@ DB2627DE17B96727009DA3A6 /* SLStatusBarTest.m in Sources */, F078C0491808BF24000767D2 /* SLWebViewTest.m in Sources */, DB2627DF17B96727009DA3A6 /* SLStatusBarTestViewController.m in Sources */, + 97068F8F18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.m in Sources */, 50A59BD81784908D002A863A /* SLGeometryTest.m in Sources */, 50A59BDB178490C2002A863A /* SLGeometryTestViewController.m in Sources */, ); From 0a30c47be2c5b8fab135e6ed0e38d27499b24d87 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 16:15:06 -0700 Subject: [PATCH 14/20] Added SLTableViewCell subclass of SLAccessibilityContainer --- .../Classes/Internal/NSObject+SLVisibility.m | 5 --- .../User Interface Elements/SLTableViewCell.h | 24 +++++++++++ .../User Interface Elements/SLTableViewCell.m | 40 +++++++++++++++++++ Subliminal.xcodeproj/project.pbxproj | 8 ++++ 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h create mode 100644 Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m diff --git a/Sources/Classes/Internal/NSObject+SLVisibility.m b/Sources/Classes/Internal/NSObject+SLVisibility.m index 199d6ff..e5d678e 100644 --- a/Sources/Classes/Internal/NSObject+SLVisibility.m +++ b/Sources/Classes/Internal/NSObject+SLVisibility.m @@ -133,11 +133,6 @@ - (BOOL)slAccessibilityIsVisible { // if another element comes before us/our parent in the array // (thus is z-ordered before us/our parent) // and contains our hitpoint, it covers us -// SLLogAsync(@"element is %@", [element description]); -// SLLogAsync(@"element is %@", element); -// SLLogAsync(@"element frame is %@", NSStringFromCGRect([element accessibilityFrame])); -// SLLogAsync(@"testPoint is %@", NSStringFromCGPoint(testPoint)); -// SLLogAsync(@"container frame is %@", NSStringFromCGRect([container accessibilityFrame])); if (![NSStringFromClass([element class]) isEqualToString:@"UITableTextAccessibilityElement"] && CGRectContainsPoint([element accessibilityFrame], testPoint)) return NO; } diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h new file mode 100644 index 0000000..4f4e1af --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -0,0 +1,24 @@ +// +// SLTableViewCell.h +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLAccessibilityContainer.h" + +@interface SLTableViewCell : SLAccessibilityContainer + +- (instancetype)initTableViewCellWithElement:(SLElement *)element; + ++ (instancetype)tableViewCellWithElement:(SLElement *)element; + ++ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer; ++ (instancetype)tableViewCellWithLabel:(NSString *)label; ++ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; + +//- (id)childElementMatching:(SLElement *)childElement; ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement; + +@end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m new file mode 100644 index 0000000..2fbf440 --- /dev/null +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -0,0 +1,40 @@ +// +// SLTableViewCell.m +// Subliminal +// +// Created by Jordan Zucker on 4/2/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTableViewCell.h" + +@implementation SLTableViewCell + +- (instancetype)initTableViewCellWithElement:(SLElement *)element +{ + return [self initContainerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; +} + ++ (instancetype)tableViewCellWithElement:(SLElement *)element +{ + return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; +} + ++ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer +{ + return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; +} ++ (instancetype)tableViewCellWithLabel:(NSString *)label +{ + return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; +} ++ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits +{ + return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; +} ++ (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement +{ + return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; +} + +@end diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index ea8867e..47c4d04 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; }; + 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -288,6 +290,8 @@ 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLTableViewCellChildElementsTestViewController.xib; sourceTree = ""; }; 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAccessibilityContainer.h; sourceTree = ""; }; 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; + 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLTableViewCell.h; sourceTree = ""; }; + 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCell.m; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -800,6 +804,8 @@ F0A04E1C1749F70F002C7520 /* SLElement.m */, 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */, 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */, + 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */, + 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */, F043469D175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.h */, F043469E175ACE3A00D91F7F /* NSObject+SLAccessibilityDescription.m */, CAC3883D1643503C00F995F9 /* NSObject+SLAccessibilityHierarchy.h */, @@ -1035,6 +1041,7 @@ F0695E1C16014491000B05D0 /* Subliminal.h in Headers */, F0695E1D16014491000B05D0 /* SLTestController.h in Headers */, F0695E1E16014491000B05D0 /* SLTest.h in Headers */, + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */, F0695E1F16014491000B05D0 /* SLTerminal.h in Headers */, F0695E2016014491000B05D0 /* SLUIAElement.h in Headers */, 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */, @@ -1334,6 +1341,7 @@ CA75E78516697C0000D57E92 /* SLDevice.m in Sources */, F0C07A391703F95B00C93F93 /* SLAlert.m in Sources */, F0C07A481703FEF600C93F93 /* SLButton.m in Sources */, + 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */, F0C07A4C1704002100C93F93 /* SLTextField.m in Sources */, F0C07A501704009E00C93F93 /* SLWindow.m in Sources */, F0C07A541704011400C93F93 /* SLKeyboard.m in Sources */, From 9e6d1d781d4bd1e78754ff3b1348acd46f4bac5f Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 17:06:59 -0700 Subject: [PATCH 15/20] Added test for TableViewCell methods --- .../Tests/SLTableViewCellChildElementsTest.m | 61 +++++++++++++++++++ Sources/Subliminal.h | 1 + Subliminal.xcodeproj/project.pbxproj | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index 5bd24fa..e474177 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -341,6 +341,67 @@ - (void)testMatchingTableViewCellWithNewMethod // [favoriteButton logElementTree]; +} + +- (void)testMatchingTableViewCellWithNewMethodSubclass +{ + // [[SLWindow mainWindow] logElementTree]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; + //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; + // SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; + // cell2.parentElementType = SLTableViewCellElement; + // //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; + // SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; + // SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; + SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // + // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); + // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); + // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; + + + // SLLogAsync(@"testing"); + // SLLogAsync(@"favoriteButton is %@", favoriteButton); + // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); + // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); + // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); + // SLLogAsync(@"now log element tree for favorite button"); + // [favoriteButton logElementTree]; + + } diff --git a/Sources/Subliminal.h b/Sources/Subliminal.h index 8c93fc6..c5f70f9 100644 --- a/Sources/Subliminal.h +++ b/Sources/Subliminal.h @@ -29,6 +29,7 @@ #import "NSObject+SLAccessibilityDescription.h" #import "NSObject+SLAccessibilityHierarchy.h" #import "SLAccessibilityContainer.h" +#import "SLTableViewCell.h" #import "SLStaticElement.h" #import "SLAlert.h" #import "SLButton.h" diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index 47c4d04..4d5246a 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -48,7 +48,7 @@ 97068F9018ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97068F8B18ECB5AF005FE660 /* SLTableViewCellChildElementsTestViewController.xib */; }; 97068F9718ECB5EA005FE660 /* SLAccessibilityContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9518ECB5EA005FE660 /* SLAccessibilityContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; - 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; }; + 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; From 786d7b4f9d2de4dab1ddf8828a99cad0f53580e0 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 2 Apr 2014 17:11:59 -0700 Subject: [PATCH 16/20] Cleaned up comments --- .../Tests/SLTableViewCellChildElementsTest.m | 480 +----------------- .../SLAccessibilityContainer.m | 2 - 2 files changed, 2 insertions(+), 480 deletions(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index e474177..ef3b023 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -28,10 +28,6 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; -// SLLogAsync(@"favoritButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton recursive is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -42,7 +38,6 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -55,155 +50,10 @@ - (void)testTapBroadMatchingTableViewCellButton { [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; } -//- (void)testOriginalHackMatchingTableViewCell -//{ -//// [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { -// -// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { -// -// id accessibilityParent = [obj slAccessibilityParent]; -// -// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); -// while (accessibilityParent && ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"]) { -// -// accessibilityParent = [accessibilityParent slAccessibilityParent]; -// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); -// -// } -// -// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); -// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; -// -// } -// -// return NO; -// -// } withDescription:@"searching for favoritebutton"]; -// -//// SLLogAsync(@"favoriteButton is %@", favoriteButton); -//// -//// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [favoriteButton isValidAndVisible]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -//// SLLogAsync(@"testing"); -//// SLLogAsync(@"favoriteButton is %@", favoriteButton); -//// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -//// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -//// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -//// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; -// -// -//} - -//- (void)testOriginalHackMatchingTableViewCellWithNoAXMatching -//{ -//// [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { -// -// if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { -// -// id accessibilityParent = [obj slAccessibilityParent]; -// -// //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); -// while (accessibilityParent && (![accessibilityParent isKindOfClass:[UITableViewCell class]] || ![NSStringFromClass([accessibilityParent class]) isEqualToString:@"UITableViewCellAccessibilityElement"])) { -// -// accessibilityParent = [accessibilityParent slAccessibilityParent]; -// //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); -// -// } -// -// //SLLogAsync(@"[accessibilityParent accessibilityLabel] is %@", [accessibilityParent accessibilityLabel]); -// return [[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]; -// -// } -// -// return NO; -// -// } withDescription:@"searching for favoritebutton"]; -// -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// -// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// //SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// //SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; -// -// -//} - - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView { -// [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { @@ -211,11 +61,9 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView id accessibilityParent = [obj slAccessibilityParent]; - //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); while (accessibilityParent && ![[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; - //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); } @@ -240,13 +88,7 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView } withDescription:@"searching for favoritebutton"]; -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// -// SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -256,7 +98,6 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -269,43 +110,17 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - -// SLLogAsync(@"testing"); -// SLLogAsync(@"favoriteButton is %@", favoriteButton); -// SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// SLLogAsync(@"now log element tree for favorite button"); -// [favoriteButton logElementTree]; - - } -- (void)testMatchingTableViewCellWithNewMethod +- (void)testMatchingTableViewCellWithAccessibilityContainerMethod { - // [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// cell2.parentElementType = SLTableViewCellElement; -// //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // - // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); - // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); - // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -317,7 +132,6 @@ - (void)testMatchingTableViewCellWithNewMethod [UIAElement(favoriteButton) isValidAndVisible]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -330,43 +144,17 @@ - (void)testMatchingTableViewCellWithNewMethod [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - - // SLLogAsync(@"testing"); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); - // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); - // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); - // SLLogAsync(@"now log element tree for favorite button"); - // [favoriteButton logElementTree]; - - } -- (void)testMatchingTableViewCellWithNewMethodSubclass +- (void)testMatchingTableViewCellWithTableViewCellMethodSubclass { - // [[SLWindow mainWindow] logElementTree]; [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; - //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; - // SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; - // cell2.parentElementType = SLTableViewCellElement; - // //SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; - // SLButton *matchingFavoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; - // SLElement *favoriteButton = [cell2 achildElementMatching:matchingFavoriteButton]; SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // - // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); - // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); - // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; @@ -378,7 +166,6 @@ - (void)testMatchingTableViewCellWithNewMethodSubclass [UIAElement(favoriteButton) isValidAndVisible]; - //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); [UIAElement(favoriteButton) tap]; @@ -391,269 +178,6 @@ - (void)testMatchingTableViewCellWithNewMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; - - - // SLLogAsync(@"testing"); - // SLLogAsync(@"favoriteButton is %@", favoriteButton); - // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); - // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); - // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); - // SLLogAsync(@"now log element tree for favorite button"); - // [favoriteButton logElementTree]; - - } - -//- (void)testMatchingTableViewCellWithNewMethod -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodTVCSubclass -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent elementWithAccessibilityLabel:@"Cell 2"]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// //SLAccessibilityParent *cell2 = [SLAccessibilityParent parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"] andParentType:SLTableViewCellElement]; -// SLTableViewCell *cell2 = [SLTableViewCell parentWithDescriptor:[SLElementDescriptor descriptorWithLabel:@"Cell 2"]]; -// SLElementDescriptor *favoriteDescriptor = [SLElementDescriptor descriptorWithLabel:@"Favorite"]; -// SLElement *favoriteButton = [cell2 childElementMatching:favoriteDescriptor]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - - -//- (void)testMatchingTableViewCellWithNewMethod -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:UIAccessibilityTraitButton inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodAnyTraits -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - -//- (void)testMatchingTableViewCellWithNewMethodAnyTraitsAndElement -//{ -// // [[SLWindow mainWindow] logElementTree]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; -// SLElement *favoriteButton = [SLElement elementWithAccessibilityLabel:@"Favorite" value:nil traits:SLUIAccessibilityTraitAny inTableViewCellWithLabel:@"Cell 2" andValue:nil]; -// -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // -// // SLLogAsync(@"favoriteButton isValidAndVisible is %d", [UIAElement(favoriteButton) isValidAndVisible]); -// // SLLogAsync(@"favoriteButton value is %@", [UIAElement(favoriteButton) value]); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); -// // SLLogAsync(@"favoriteButton isValid is %d", [UIAElement(favoriteButton) isValid]); -// // SLLogAsync(@"favoriteButton isVisible is %d", [UIAElement(favoriteButton) isVisible]); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; -// -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; -// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; -// -// //SLButton *unfavoriteButton = [SLButton elementWithAccessibilityLabel:@"Unfavorite"]; -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); -// [UIAElement(favoriteButton) tap]; -// -// [self wait:1]; -// -// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); -// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); -// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; -// -// -// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -// -// -// // SLLogAsync(@"testing"); -// // SLLogAsync(@"favoriteButton is %@", favoriteButton); -// // SLLogAsync(@"favoriteButton description is %@", [favoriteButton slAccessibilityDescription]); -// // SLLogAsync(@"favoriteButton parent is %@", [favoriteButton slAccessibilityParent]); -// // SLLogAsync(@"favoriteButton recursive description is %@", [favoriteButton slRecursiveAccessibilityDescription]); -// // SLLogAsync(@"now log element tree for favorite button"); -// // [favoriteButton logElementTree]; -// -// -//} - - @end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 0fa5525..6106913 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -48,12 +48,10 @@ - (id)childElementMatching:(SLElement *)childElement id accessibilityParent = [obj slAccessibilityParent]; - //SLLogAsync(@"starting: accessibilityParent is %@", accessibilityParent); // then look for child element having matching parent while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; - //SLLogAsync(@"get accessibilityParent that is now %@", accessibilityParent); } From bae103aec63807f1c042dfd77fa989d8ba947574 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Fri, 4 Apr 2014 14:10:12 -0700 Subject: [PATCH 17/20] Updated SLAccessibilityContainer to be true subclass. --- .../Tests/SLNavigationBarTests.m | 58 ++++++++++++++++ .../SLNavigationBarTestsViewController.m | 67 +++++++++++++++++++ .../SLNavigationBarTestsViewController.xib | 33 +++++++++ .../Tests/SLTableViewCellChildElementsTest.m | 34 ++++++++++ ...eViewCellChildElementsTestViewController.m | 1 - .../SLAccessibilityContainer.h | 8 +-- .../SLAccessibilityContainer.m | 57 ++++++++++------ .../User Interface Elements/SLTableViewCell.h | 3 +- .../User Interface Elements/SLTableViewCell.m | 43 ++++++++++-- Subliminal.xcodeproj/project.pbxproj | 20 ++++++ 10 files changed, 293 insertions(+), 31 deletions(-) create mode 100644 Integration Tests/Tests/SLNavigationBarTests.m create mode 100644 Integration Tests/Tests/SLNavigationBarTestsViewController.m create mode 100644 Integration Tests/Tests/SLNavigationBarTestsViewController.xib diff --git a/Integration Tests/Tests/SLNavigationBarTests.m b/Integration Tests/Tests/SLNavigationBarTests.m new file mode 100644 index 0000000..228e6a2 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTests.m @@ -0,0 +1,58 @@ +// +// SLNavigationBarTests.m +// Subliminal +// +// Created by Jordan Zucker on 4/4/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLIntegrationTest.h" + +@interface focus_SLNavigationBarTests : SLIntegrationTest + +@end + +@implementation focus_SLNavigationBarTests + ++ (NSString *)testCaseViewControllerClassName { + return @"SLNavigationBarTestsViewController"; +} + +// If you override set-up methods, +// you must call super at the beginning of your implementations. + +// If you override tear-down methods, +// you must call super at the *end* of your implementations. + +- (void)testRightButtonBroadMatching { + SLButton *rightButton = [SLButton elementWithAccessibilityLabel:@"Right"]; + SLAssertTrue([UIAElement(rightButton) isValidAndVisible], @"Right button didn't appear"); + + [UIAElement(rightButton) tap]; +} + +- (void)testRightButtonWithNewMethod +{ + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLLogAsync(@"navBar is %@", navBar); + SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); + SLButton *rightButton = [navBar childElementMatching:[SLButton elementWithAccessibilityLabel:@"Right"]]; + SLAssertTrue([UIAElement(rightButton) isValidAndVisible], @"Couldn't find right button bar"); + + [UIAElement(rightButton) tap]; + +} + +- (void)testTitleLabel +{ + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLLogAsync(@"navBar is %@", navBar); + SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); + SLElement *title = [navBar childElementMatching:[SLElement elementWithAccessibilityLabel:@"Testing" value:nil traits:UIAccessibilityTraitStaticText]]; + SLAssertTrue([UIAElement(title) isValidAndVisible], @"title isn't valid and visible"); + SLLogAsync(@"title is %@", title.label); + SLAssertTrue([UIAElement(title.label) isEqualToString:@"Testing"], @"title doesn't match expected string"); + +} + +@end diff --git a/Integration Tests/Tests/SLNavigationBarTestsViewController.m b/Integration Tests/Tests/SLNavigationBarTestsViewController.m new file mode 100644 index 0000000..e4b7d52 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTestsViewController.m @@ -0,0 +1,67 @@ +// +// SLNavigationBarTestsViewController.m +// Subliminal +// +// Created by Jordan Zucker on 4/4/14. +// Copyright (c) 2014 Inkling. All rights reserved. +// + +#import "SLTestCaseViewController.h" + +#import + +@interface SLNavigationBarTestsViewController : SLTestCaseViewController + +@end + +@interface SLNavigationBarTestsViewController () +// Connect IBOutlets here. +@property (nonatomic, weak) IBOutlet UINavigationBar *navBar; +@end + +@implementation SLNavigationBarTestsViewController + ++ (NSString *)nibNameForTestCase:(SEL)testCase { + return @"SLNavigationBarTestsViewController"; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Do any additional setup after loading the view from its nib. + // Test case specific configuration is best done using app hooks + // triggered from -[SLNavigationBarTests setUpTestCaseWithSelector:]. + UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBarButtonItemStylePlain target:self action:@selector(tapRightButton:)]; + rightButton.accessibilityLabel = @"Right"; + _navBar.topItem.rightBarButtonItem = rightButton; + + _navBar.accessibilityIdentifier = @"NavigationBar"; + + _navBar.topItem.title = @"Testing"; + _navBar.topItem.title.isAccessibilityElement = YES; + _navBar.topItem.title.accessibilityLabel = _navBar.topItem.title; +} + +- (IBAction)tapRightButton:(id)sender +{ + NSLog(@"hey"); +} + +- (instancetype)initWithTestCaseWithSelector:(SEL)testCase { + self = [super initWithTestCaseWithSelector:testCase]; + if (self) { + // Register for app hooks, e.g. + // [[SLTestController sharedTestController] registerTarget:<#(id)#> forAction:<#(SEL)#>]; + } + return self; +} + +// Deregister for app hooks, if any +//- (void)dealloc { +// [[SLTestController sharedTestController] deregisterTarget:self]; +//} + +//#pragma mark - App hooks +// Put any app hooks below here + +@end diff --git a/Integration Tests/Tests/SLNavigationBarTestsViewController.xib b/Integration Tests/Tests/SLNavigationBarTestsViewController.xib new file mode 100644 index 0000000..518af47 --- /dev/null +++ b/Integration Tests/Tests/SLNavigationBarTestsViewController.xib @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index ef3b023..24e6c36 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -180,4 +180,38 @@ - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; } +- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex +{ + [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; + SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; + SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; + + SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; + + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; + [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; + + [UIAElement(favoriteButton) isValidAndVisible]; + + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); + [UIAElement(favoriteButton) tap]; + + [self wait:1]; + + SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); + SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); + [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; + + + [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +} + @end diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m index 25d0f08..79e0043 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTestViewController.m @@ -132,7 +132,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } cell.textLabel.text = [_tableViewElements objectAtIndex:indexPath.row]; - //UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; //[favoriteButton setTitle:@"Favorite" forState:UIControlStateNormal]; UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h index 902fb36..fde9779 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -10,16 +10,16 @@ typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { SLTableViewAccessibilityContainer, - SLCollectionViewAccessibilityContainer + SLCollectionViewAccessibilityContainer, + SLNavigationBarContainer, + SLToolbarContainer, + SLTabBarContainer }; @interface SLAccessibilityContainer : SLElement -@property (nonatomic) SLElement *containerElement; @property (nonatomic, assign) SLAccessibilityContainerType containerType; -- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; - + (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; + (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 6106913..4f9a98f 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -12,32 +12,38 @@ @implementation SLAccessibilityContainer -- (instancetype)initContainerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType -{ - self = [super init]; - if (self) { - _containerElement = element; - _containerType = accessibilityContainerType; - } - return self; -} - + (instancetype)containerWithElement:(SLElement *)element andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:element andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [element matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithIdentifier:(NSString *)identifer andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityIdentifier:identifer] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityIdentifier:identifer] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithLabel:(NSString *)label andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityLabel:label] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } + (instancetype)containerWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits andContainerType:(SLAccessibilityContainerType)accessibilityContainerType { - return [[self alloc] initContainerWithElement:[SLElement elementWithAccessibilityLabel:label value:value traits:traits] andContainerType:accessibilityContainerType]; + SLAccessibilityContainer *container = [SLAccessibilityContainer elementMatching:^BOOL(NSObject *obj) { + return [[SLElement elementWithAccessibilityLabel:label value:value traits:traits] matchesObject:obj]; + } withDescription:@"container"]; + container.containerType = accessibilityContainerType; + return container; } - (id)childElementMatching:(SLElement *)childElement @@ -49,15 +55,11 @@ - (id)childElementMatching:(SLElement *)childElement id accessibilityParent = [obj slAccessibilityParent]; // then look for child element having matching parent - while (accessibilityParent && ![_containerElement matchesObject:accessibilityParent]) { + while (accessibilityParent && ![self matchesObject:accessibilityParent]) { accessibilityParent = [accessibilityParent slAccessibilityParent]; } - - - id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; - Class compareClass; switch (_containerType) { case SLTableViewAccessibilityContainer: @@ -66,11 +68,26 @@ - (id)childElementMatching:(SLElement *)childElement case SLCollectionViewAccessibilityContainer: compareClass = [UICollectionView class]; break; - + case SLNavigationBarContainer: + compareClass = [UINavigationBar class]; + break; + case SLTabBarContainer: + compareClass = [UITabBar class]; + break; + case SLToolbarContainer: + compareClass = [UIToolbar class]; + break; + default: compareClass = [UIView class]; break; } + if ((_containerType == SLNavigationBarContainer) || (_containerType == SLTabBarContainer) || (_containerType == SLToolbarContainer)) { + return [accessibilityParent isKindOfClass:compareClass]; + } + + + id doubleAccessibilityParent = [accessibilityParent slAccessibilityParent]; while (doubleAccessibilityParent && ![doubleAccessibilityParent isKindOfClass:compareClass]) { doubleAccessibilityParent = [doubleAccessibilityParent slAccessibilityParent]; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index 4f4e1af..ee771a8 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -10,7 +10,6 @@ @interface SLTableViewCell : SLAccessibilityContainer -- (instancetype)initTableViewCellWithElement:(SLElement *)element; + (instancetype)tableViewCellWithElement:(SLElement *)element; @@ -18,6 +17,8 @@ + (instancetype)tableViewCellWithLabel:(NSString *)label; + (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; +//+ (instancetype)tableViewCellAtIndexPath:(NSIndexPath *)indexPath; + //- (id)childElementMatching:(SLElement *)childElement; + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2fbf440..2291fe6 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -7,14 +7,11 @@ // #import "SLTableViewCell.h" +#import "SLUIAElement+Subclassing.h" +#import "NSObject+SLAccessibilityHierarchy.h" @implementation SLTableViewCell -- (instancetype)initTableViewCellWithElement:(SLElement *)element -{ - return [self initContainerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; -} - + (instancetype)tableViewCellWithElement:(SLElement *)element { return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; @@ -37,4 +34,40 @@ + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLEleme return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; } +//+ (id)tableViewCellAtIndexPath:(NSIndexPath *)indexPath +//{ +// SLTableViewCell *cell = [SLTableViewCell elementMatching:^BOOL(NSObject *obj) { +// id accessibilityParent = [obj slAccessibilityParent]; +// +// // then look for child element having matching parent +// while (accessibilityParent && ![accessibilityParent isKindOfClass:[UITableView class]]) { +// +// accessibilityParent = [accessibilityParent slAccessibilityParent]; +// +// } +// if ([accessibilityParent isKindOfClass:[UITableView class]]) { +// //NSIndexPath * +// NSLog(@"----------------------------------------------- Properties for object %@", self); +// +// @autoreleasepool { +// unsigned int numberOfProperties = 0; +// objc_property_t *propertyArray = class_copyPropertyList([self class], &numberOfProperties); +// for (NSUInteger i = 0; i < numberOfProperties; i++) { +// objc_property_t property = propertyArray[i]; +// NSString *name = [[NSString alloc] initWithUTF8String:property_getName(property)]; +// NSLog(@"Property %@ Value: %@", name, [self valueForKey:name]); +// SLLogAsync(@"Property %@ Value: %@", name, [self valueForKey:name]); +// } +// free(propertyArray); +// } +// NSLog(@"-----------------------------------------------"); +// return NO; +// //return [indexPath compare:[]]; +// } +// return NO; +// } withDescription:@"container"]; +// cell.containerType = SLTableViewAccessibilityContainer; +// return cell; +//} + @end diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index 4d5246a..f07b87a 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -50,6 +50,9 @@ 97068F9818ECB5EA005FE660 /* SLAccessibilityContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */; }; 97068F9B18ECCFCB005FE660 /* SLTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 97068F9C18ECCFCB005FE660 /* SLTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */; }; + 97AC17D718EF2B0F00B42B66 /* SLNavigationBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */; }; + 97AC17D818EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */; }; + 97AC17D918EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */; }; CA75E78216697A1200D57E92 /* SLDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CA75E78016697A1200D57E92 /* SLDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA75E78516697C0000D57E92 /* SLDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = CA75E78116697A1200D57E92 /* SLDevice.m */; }; CAC388051641CD7500F995F9 /* SLStringUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC388031641CD7500F995F9 /* SLStringUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -292,6 +295,9 @@ 97068F9618ECB5EA005FE660 /* SLAccessibilityContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAccessibilityContainer.m; sourceTree = ""; }; 97068F9918ECCFCB005FE660 /* SLTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLTableViewCell.h; sourceTree = ""; }; 97068F9A18ECCFCB005FE660 /* SLTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLTableViewCell.m; sourceTree = ""; }; + 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLNavigationBarTests.m; sourceTree = ""; }; + 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLNavigationBarTestsViewController.m; sourceTree = ""; }; + 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SLNavigationBarTestsViewController.xib; sourceTree = ""; }; CA75E78016697A1200D57E92 /* SLDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLDevice.h; sourceTree = ""; }; CA75E78116697A1200D57E92 /* SLDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLDevice.m; sourceTree = ""; }; CAC388031641CD7500F995F9 /* SLStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLStringUtilities.h; sourceTree = ""; }; @@ -548,6 +554,16 @@ name = "SLTableViewCellChildElements Tests"; sourceTree = ""; }; + 97AC17DD18EF2B1B00B42B66 /* New Group */ = { + isa = PBXGroup; + children = ( + 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */, + 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */, + 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */, + ); + name = "New Group"; + sourceTree = ""; + }; CAC388011641CD4800F995F9 /* Internal */ = { isa = PBXGroup; children = ( @@ -949,6 +965,7 @@ F013798E16D0843B009BAF22 /* SLTerminal Tests */, F078C0431808BF0D000767D2 /* SLWebView Tests */, F089F98E17458B7400DF1F25 /* SLWindow Tests */, + 97AC17DD18EF2B1B00B42B66 /* New Group */, ); path = Tests; sourceTree = ""; @@ -1250,6 +1267,7 @@ F0E80D8816DB2CEB00945D25 /* SLElementVisibilityTestElementContainerHidden.xib in Resources */, F0E80D8916DB2CEB00945D25 /* SLElementVisibilityTestElementCovered.xib in Resources */, F0E80D8A16DB2CEB00945D25 /* SLElementVisibilityTestElementOffscreen.xib in Resources */, + 97AC17D918EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib in Resources */, F043A9BE1729CFFE00A4FD1D /* SLElementVisibilityTestElementHidden.xib in Resources */, F043A9C01729EFD100A4FD1D /* SLElementVisibilityTestUserInteractionDisabled.xib in Resources */, F043A9C7172A160600A4FD1D /* SLElementVisibilityTest.html in Resources */, @@ -1365,6 +1383,7 @@ buildActionMask = 2147483647; files = ( 2C903BC017F525E700555317 /* SLSwitchTest.m in Sources */, + 97AC17D818EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m in Sources */, F0AC80A016BB299500C5D5C0 /* main.m in Sources */, F0AC80A416BB299500C5D5C0 /* SLIntegrationTestsAppDelegate.m in Sources */, F0AC80BD16BB50FF00C5D5C0 /* SLTestsViewController.m in Sources */, @@ -1372,6 +1391,7 @@ F0AC80C416BC355D00C5D5C0 /* SLTerminalTest.m in Sources */, F0AC80C116BB559F00C5D5C0 /* SLIntegrationTest.m in Sources */, F0AC80C816BC367E00C5D5C0 /* SLTestViewController.m in Sources */, + 97AC17D718EF2B0F00B42B66 /* SLNavigationBarTests.m in Sources */, F078C04A1808BF24000767D2 /* SLWebViewTestViewController.m in Sources */, F0AC80E616BCF91800C5D5C0 /* SLTestCaseViewController.m in Sources */, 06953E3F178FDA7100B3D1B7 /* SLElementTouchAndHoldTest.m in Sources */, From d2bab85b48f6ef4fbb3496e862b80814e272d9c2 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Fri, 4 Apr 2014 14:34:22 -0700 Subject: [PATCH 18/20] Cleaned up method names for table view cells --- .../Tests/SLTableViewCellChildElementsTest.m | 68 +++++++++---------- .../User Interface Elements/SLTableViewCell.h | 8 +-- .../User Interface Elements/SLTableViewCell.m | 8 +-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index 24e6c36..f10b2c8 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -149,7 +149,7 @@ - (void)testMatchingTableViewCellWithAccessibilityContainerMethod - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellWithLabel:@"Cell 2"]; + SLTableViewCell *tableViewCell = [SLTableViewCell cellWithLabel:@"Cell 2"]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); @@ -180,38 +180,38 @@ - (void)testMatchingTableViewCellWithTableViewCellMethodSubclass [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; } -- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex -{ - [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLTableViewCell *tableViewCell = [SLTableViewCell tableViewCellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; - SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; - - SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); - - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); - [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; - - [UIAElement(favoriteButton) tap]; - - [self wait:1]; - [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; - [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; - - [UIAElement(favoriteButton) isValidAndVisible]; - - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); - [UIAElement(favoriteButton) tap]; - - [self wait:1]; - - SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); - SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); - [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; - - - [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; -} +//- (void)testMatchingTableViewCellWithTableViewCellMethodSubclassIndex +//{ +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; +// SLTableViewCell *tableViewCell = [SLTableViewCell cellAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]]; +// SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; +// +// SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not originally off"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: starting"]; +// +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"after tap"]; +// [favoriteButton captureScreenshotWithFilename:@"fb: after first tap"]; +// +// [UIAElement(favoriteButton) isValidAndVisible]; +// +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"favorite button is not valid and visible after first time tapping"); +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"on"], @"Favorite button does not has ax value of on"); +// [UIAElement(favoriteButton) tap]; +// +// [self wait:1]; +// +// SLAssertTrue([UIAElement(favoriteButton.value) isEqualToString:@"off"], @"favorite button is not off at end of test"); +// SLAssertTrue([UIAElement(favoriteButton) isValidAndVisible], @"Favorite button is not valid and visible"); +// [favoriteButton captureScreenshotWithFilename:@"fb: ending"]; +// +// +// [[SLDevice currentDevice] captureScreenshotWithFilename:@"end of test"]; +//} @end diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index ee771a8..1e6aa3b 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -11,11 +11,11 @@ @interface SLTableViewCell : SLAccessibilityContainer -+ (instancetype)tableViewCellWithElement:(SLElement *)element; ++ (instancetype)cellWithElement:(SLElement *)element; -+ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer; -+ (instancetype)tableViewCellWithLabel:(NSString *)label; -+ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; ++ (instancetype)cellWithIdentifier:(NSString *)identifer; ++ (instancetype)cellWithLabel:(NSString *)label; ++ (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits; //+ (instancetype)tableViewCellAtIndexPath:(NSIndexPath *)indexPath; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2291fe6..2a3cf98 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -12,20 +12,20 @@ @implementation SLTableViewCell -+ (instancetype)tableViewCellWithElement:(SLElement *)element ++ (instancetype)cellWithElement:(SLElement *)element { return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithIdentifier:(NSString *)identifer ++ (instancetype)cellWithIdentifier:(NSString *)identifer { return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithLabel:(NSString *)label ++ (instancetype)cellWithLabel:(NSString *)label { return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; } -+ (instancetype)tableViewCellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits ++ (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits { return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; } From 0e9c612b1fa63ff400f719d2092bbe6114ec45da Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Mon, 7 Apr 2014 12:06:19 -0700 Subject: [PATCH 19/20] Cleaned up enum for AX container types --- Integration Tests/Tests/SLNavigationBarTests.m | 4 ++-- .../Tests/SLTableViewCellChildElementsTest.m | 2 +- .../SLAccessibilityContainer.h | 10 +++++----- .../SLAccessibilityContainer.m | 12 ++++++------ .../User Interface Elements/SLTableViewCell.h | 1 + .../User Interface Elements/SLTableViewCell.m | 10 +++++----- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Integration Tests/Tests/SLNavigationBarTests.m b/Integration Tests/Tests/SLNavigationBarTests.m index 228e6a2..9850189 100644 --- a/Integration Tests/Tests/SLNavigationBarTests.m +++ b/Integration Tests/Tests/SLNavigationBarTests.m @@ -33,7 +33,7 @@ - (void)testRightButtonBroadMatching { - (void)testRightButtonWithNewMethod { - SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLAccessibilityContainerTypeNavigationBar]; SLLogAsync(@"navBar is %@", navBar); SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); SLButton *rightButton = [navBar childElementMatching:[SLButton elementWithAccessibilityLabel:@"Right"]]; @@ -45,7 +45,7 @@ - (void)testRightButtonWithNewMethod - (void)testTitleLabel { - SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLNavigationBarContainer]; + SLAccessibilityContainer *navBar = [SLAccessibilityContainer containerWithIdentifier:@"NavigationBar" andContainerType:SLAccessibilityContainerTypeNavigationBar]; SLLogAsync(@"navBar is %@", navBar); SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); SLElement *title = [navBar childElementMatching:[SLElement elementWithAccessibilityLabel:@"Testing" value:nil traits:UIAccessibilityTraitStaticText]]; diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index f10b2c8..58851ae 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -115,7 +115,7 @@ - (void)testMatchingTableViewCellByMatchingTableViewCellAndTableView - (void)testMatchingTableViewCellWithAccessibilityContainerMethod { [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; - SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLTableViewAccessibilityContainer]; + SLAccessibilityContainer *tableViewCell = [SLAccessibilityContainer containerWithLabel:@"Cell 2" andContainerType:SLAccessibilityContainerTypeTableViewCell]; SLButton *favoriteButton = [tableViewCell childElementMatching:[SLButton elementWithAccessibilityLabel:@"Favorite"]]; SLLogAsync(@"favoriteButton.value is %@", UIAElement(favoriteButton.value)); diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h index fde9779..82fa4d2 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.h @@ -9,11 +9,11 @@ #import "SLElement.h" typedef NS_ENUM(NSInteger, SLAccessibilityContainerType) { - SLTableViewAccessibilityContainer, - SLCollectionViewAccessibilityContainer, - SLNavigationBarContainer, - SLToolbarContainer, - SLTabBarContainer + SLAccessibilityContainerTypeTableViewCell, + SLAccessibilityContainerTypeCollectionViewCell, + SLAccessibilityContainerTypeNavigationBar, + SLAccessibilityContainerTypeToolbar, + SLAccessibilityContainerTypeTabBar }; @interface SLAccessibilityContainer : SLElement diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m index 4f9a98f..4e915a6 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLAccessibilityContainer.m @@ -62,19 +62,19 @@ - (id)childElementMatching:(SLElement *)childElement } Class compareClass; switch (_containerType) { - case SLTableViewAccessibilityContainer: + case SLAccessibilityContainerTypeTableViewCell: compareClass = [UITableView class]; break; - case SLCollectionViewAccessibilityContainer: + case SLAccessibilityContainerTypeCollectionViewCell: compareClass = [UICollectionView class]; break; - case SLNavigationBarContainer: + case SLAccessibilityContainerTypeNavigationBar: compareClass = [UINavigationBar class]; break; - case SLTabBarContainer: + case SLAccessibilityContainerTypeTabBar: compareClass = [UITabBar class]; break; - case SLToolbarContainer: + case SLAccessibilityContainerTypeToolbar: compareClass = [UIToolbar class]; break; @@ -82,7 +82,7 @@ - (id)childElementMatching:(SLElement *)childElement compareClass = [UIView class]; break; } - if ((_containerType == SLNavigationBarContainer) || (_containerType == SLTabBarContainer) || (_containerType == SLToolbarContainer)) { + if ((_containerType == SLAccessibilityContainerTypeTabBar) || (_containerType == SLAccessibilityContainerTypeNavigationBar) || (_containerType == SLAccessibilityContainerTypeToolbar)) { return [accessibilityParent isKindOfClass:compareClass]; } diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h index 1e6aa3b..e3d6ec0 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.h @@ -12,6 +12,7 @@ + (instancetype)cellWithElement:(SLElement *)element; +//+ (instancetype)cellWithElement:(SLElement *)element inTableViewWithIdentifier:(NSString *)identifier; + (instancetype)cellWithIdentifier:(NSString *)identifer; + (instancetype)cellWithLabel:(NSString *)label; diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m index 2a3cf98..1291cae 100644 --- a/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m +++ b/Sources/Classes/UIAutomation/User Interface Elements/SLTableViewCell.m @@ -14,24 +14,24 @@ @implementation SLTableViewCell + (instancetype)cellWithElement:(SLElement *)element { - return [SLTableViewCell containerWithElement:element andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithElement:element andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithIdentifier:(NSString *)identifer { - return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithIdentifier:identifer andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithLabel:(NSString *)label { - return [SLTableViewCell containerWithLabel:label andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithLabel:label andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (instancetype)cellWithLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits { - return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell containerWithLabel:label value:value traits:traits andContainerType:SLAccessibilityContainerTypeTableViewCell]; } + (id)childElementMatching:(SLElement *)childElement inContainerElement:(SLElement *)containerElement { - return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLTableViewAccessibilityContainer]; + return [SLTableViewCell childElementMatching:childElement inContainerElement:containerElement ofContainerType:SLAccessibilityContainerTypeTableViewCell]; } //+ (id)tableViewCellAtIndexPath:(NSIndexPath *)indexPath From 0334e356c2df6377c59117292cea3c57cf719daa Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Wed, 23 Apr 2014 15:07:53 -0700 Subject: [PATCH 20/20] Removed focus from tests for official commit --- Integration Tests/Tests/SLNavigationBarTests.m | 4 ++-- Integration Tests/Tests/SLTableViewCellChildElementsTest.m | 4 ++-- Subliminal.xcodeproj/project.pbxproj | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Integration Tests/Tests/SLNavigationBarTests.m b/Integration Tests/Tests/SLNavigationBarTests.m index 9850189..95ad424 100644 --- a/Integration Tests/Tests/SLNavigationBarTests.m +++ b/Integration Tests/Tests/SLNavigationBarTests.m @@ -8,11 +8,11 @@ #import "SLIntegrationTest.h" -@interface focus_SLNavigationBarTests : SLIntegrationTest +@interface SLNavigationBarTests : SLIntegrationTest @end -@implementation focus_SLNavigationBarTests +@implementation SLNavigationBarTests + (NSString *)testCaseViewControllerClassName { return @"SLNavigationBarTestsViewController"; diff --git a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m index 58851ae..8770d75 100644 --- a/Integration Tests/Tests/SLTableViewCellChildElementsTest.m +++ b/Integration Tests/Tests/SLTableViewCellChildElementsTest.m @@ -8,11 +8,11 @@ #import "SLIntegrationTest.h" -@interface focus_SLTableViewCellChildElementsTest : SLIntegrationTest +@interface SLTableViewCellChildElementsTest : SLIntegrationTest @end -@implementation focus_SLTableViewCellChildElementsTest +@implementation SLTableViewCellChildElementsTest + (NSString *)testCaseViewControllerClassName { return @"SLTableViewCellChildElementsTestViewController"; diff --git a/Subliminal.xcodeproj/project.pbxproj b/Subliminal.xcodeproj/project.pbxproj index f07b87a..5ff5ce7 100644 --- a/Subliminal.xcodeproj/project.pbxproj +++ b/Subliminal.xcodeproj/project.pbxproj @@ -554,14 +554,14 @@ name = "SLTableViewCellChildElements Tests"; sourceTree = ""; }; - 97AC17DD18EF2B1B00B42B66 /* New Group */ = { + 97AC17DD18EF2B1B00B42B66 /* SLNavigationBar Tests */ = { isa = PBXGroup; children = ( 97AC17D418EF2B0F00B42B66 /* SLNavigationBarTests.m */, 97AC17D518EF2B0F00B42B66 /* SLNavigationBarTestsViewController.m */, 97AC17D618EF2B0F00B42B66 /* SLNavigationBarTestsViewController.xib */, ); - name = "New Group"; + name = "SLNavigationBar Tests"; sourceTree = ""; }; CAC388011641CD4800F995F9 /* Internal */ = { @@ -965,7 +965,7 @@ F013798E16D0843B009BAF22 /* SLTerminal Tests */, F078C0431808BF0D000767D2 /* SLWebView Tests */, F089F98E17458B7400DF1F25 /* SLWindow Tests */, - 97AC17DD18EF2B1B00B42B66 /* New Group */, + 97AC17DD18EF2B1B00B42B66 /* SLNavigationBar Tests */, ); path = Tests; sourceTree = "";