-
Notifications
You must be signed in to change notification settings - Fork 52
Ax parent #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Ax parent #190
Changes from all commits
698be54
a3358bd
3562e75
c129333
aae955a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // | ||
| // SLNavigationBarTests.m | ||
| // Subliminal | ||
| // | ||
| // Created by Jordan Zucker on 4/4/14. | ||
| // Copyright (c) 2014 Inkling. All rights reserved. | ||
| // | ||
|
|
||
| #import "SLIntegrationTest.h" | ||
|
|
||
| @interface SLNavigationBarTests : SLIntegrationTest | ||
| @end | ||
|
|
||
| @implementation SLNavigationBarTests | ||
|
|
||
| + (NSString *)testCaseViewControllerClassName { | ||
| return @"SLNavigationBarTestsViewController"; | ||
| } | ||
|
|
||
| - (void)testRightButtonBroadMatching { | ||
| SLButton *rightButton = [SLButton elementWithAccessibilityLabel:@"Right"]; | ||
| SLAssertTrue([UIAElement(rightButton) isValidAndVisible], @"Right button didn't appear"); | ||
|
|
||
| [UIAElement(rightButton) tap]; | ||
| } | ||
|
|
||
| - (void)testRightButtonWithNewMethod | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think something like "AsChildElement" will hold up better than "WithNewMethod" over time. |
||
| { | ||
| SLNavigationBar *navBar = [SLNavigationBar elementWithAccessibilityIdentifier:@"NavigationBar"]; | ||
| SLLogAsync(@"navBar is %@", navBar); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'm not sure what the log messages are meant to show here? |
||
| 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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think that there's a way we could test that we've matched the nav bar button in particular? Like maybe there's another button labeled "Right", but the nav bar button has a value that says "nav bar right button". |
||
|
|
||
| [UIAElement(rightButton) tap]; | ||
| } | ||
|
|
||
| - (void)testTitleLabel | ||
| { | ||
| SLNavigationBar *navBar = [SLNavigationBar elementWithAccessibilityIdentifier:@"NavigationBar"]; | ||
| SLLogAsync(@"navBar is %@", navBar); | ||
| SLAssertTrue([UIAElement(navBar) isValidAndVisible], @"Couldn't find nav bar matching specifications"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you extract this assertion into its own test case, please? It would be nice to know whether or not |
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <Subliminal/SLTestController+AppHooks.h> | ||
|
|
||
| @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 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you delete the template comments/code in the file please if unused? |
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none"> | ||
| <dependencies> | ||
| <deployment defaultVersion="1296" identifier="iOS"/> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/> | ||
| </dependencies> | ||
| <objects> | ||
| <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SLNavigationBarTestsViewController"> | ||
| <connections> | ||
| <outlet property="navBar" destination="XyI-Mm-oWe" id="HZw-AF-YMG"/> | ||
| <outlet property="view" destination="1" id="3"/> | ||
| </connections> | ||
| </placeholder> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
| <view contentMode="scaleToFill" id="1"> | ||
| <rect key="frame" x="0.0" y="0.0" width="320" height="568"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <subviews> | ||
| <navigationBar contentMode="scaleToFill" barStyle="black" translucent="NO" id="XyI-Mm-oWe"> | ||
| <rect key="frame" x="0.0" y="231" width="320" height="44"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> | ||
| <items> | ||
| <navigationItem title="Title" id="sQ4-XS-fGb"/> | ||
| </items> | ||
| </navigationBar> | ||
| </subviews> | ||
| <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
| <simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/> | ||
| <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> | ||
| <simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/> | ||
| </view> | ||
| </objects> | ||
| </document> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // | ||
| // SLTableViewCellChildElementsTest.m | ||
| // Subliminal | ||
| // | ||
| // Created by Jordan Zucker on 3/20/14. | ||
| // Copyright (c) 2014 Inkling. All rights reserved. | ||
| // | ||
|
|
||
| #import "SLIntegrationTest.h" | ||
|
|
||
| @interface SLTableViewCellChildElementsTest : SLIntegrationTest | ||
|
|
||
| @end | ||
|
|
||
| @implementation SLTableViewCellChildElementsTest | ||
|
|
||
| + (NSString *)testCaseViewControllerClassName { | ||
| return @"SLTableViewCellChildElementsTestViewController"; | ||
| } | ||
|
|
||
| - (void)testTapBroadMatchingTableViewCellButton { | ||
| [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; | ||
|
|
||
| SLButton *favoriteButton = [SLButton elementWithAccessibilityLabel:@"Favorite"]; | ||
| 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"]; | ||
|
|
||
| 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)testMatchingTableViewCellByMatchingTableViewCellAndTableView | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like maybe this test case was designed to debug the child-element method? Like it's verifying the accessibility hierarchy more than testing a particular Subliminal API? |
||
| { | ||
| [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; | ||
| SLButton *favoriteButton = [SLButton elementMatching:^BOOL(NSObject *obj) { | ||
|
|
||
| if ([obj.accessibilityLabel isEqualToString:@"Favorite"]) { | ||
|
|
||
| id accessibilityParent = [obj slAccessibilityParent]; | ||
|
|
||
| while (accessibilityParent && ![[accessibilityParent accessibilityLabel] isEqualToString:@"Cell 2"]) { | ||
|
|
||
| accessibilityParent = [accessibilityParent slAccessibilityParent]; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| 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"]; | ||
|
|
||
| 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"]; | ||
|
|
||
| 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)testMatchingTableViewCellWithAccessibilityContainerMethod | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "AsChildElement" is slightly more to-the-point. |
||
| { | ||
| [[SLDevice currentDevice] captureScreenshotWithFilename:@"start"]; | ||
| SLTableViewCell *tableViewCell = [SLTableViewCell elementWithAccessibilityLabel:@"Cell 2"]; | ||
| SLAssertTrue([UIAElement(tableViewCell) isValidAndVisible], @"table view cell matching cell 2 not valid and visible"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we extract this into a test case that |
||
| 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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think that there's a way we could test that we've matched the child of Cell 2 in particular? Like maybe each button has the same label but a cell-specific value ("Favorite 2", "Favorite 3", etc.). |
||
| [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 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Test" please.