GTXiLib sample

313 views
Skip to first unread message

Naman Vishnoi

unread,
Aug 8, 2018, 6:29:34 PM8/8/18
to ios-accessibility
Hi,

I am looking for automating accessibility testing for my iOS app. Things like when a textbox is focused, talkback takes place. That a container doesn't hide the child's accessibility.
I came across GTXiLib.

Question 1: Have I come to the correct place?

If yes, can I get any working examples with GTXLib in action? I have a bull's eye game on iOS and below is my UI Test class. I tried to disable accessibility of hit me button but the test case passed. Can someone give me a working sample, please? Or suggest some test cases based on the screenshot?

//

//  BullsEyeUITests.m

//  BullsEyeUITests

//

//  Created by Vishnoi, Naman (US - Mechanicsburg Delivery) on 8/8/18.

//  Copyright © 2018 Ray Wenderlich. All rights reserved.

//


#import <XCTest/XCTest.h>

#import <GTXiLib/GTXiLib.h>


@interface BullsEyeUITests : XCTestCase


@end


@implementation BullsEyeUITests


// Note that that is +setUp not -setUp

+ (void)setUp {

    [super setUp];

    

    // ... your other setup code (if any) comes here.

    

    // Create a new check (for example that ensures that all AX label is not an image name)

    id<GTXChecking> myNewCheck =

    [GTXCheckBlock GTXCheckWithName:@"AXlabel is not image name"

                              block:^BOOL(id element, GTXErrorRefType errorPtr) {

                                  // Ensure accessibilityLabel does not end with .png

                                  return ![[element accessibilityLabel] hasSuffix:@".png"];

                              }];

    

    // Create an array of checks to be installed.

    NSArray *checksToBeInstalled = @[

                                     [GTXChecksCollection checkForAXLabelPresent],

                                     [GTXChecksCollection checkForAXTraitDontConflict],

                                     myNewCheck,

                                     ];

    

    // Install GTX on all tests in *this* test class.

    [GTXiLib installOnTestSuite:[GTXTestSuite suiteWithAllTestsInClass:self]

                         checks:checksToBeInstalled

              elementBlacklists:@[]];

    

}


- (void)setUp {

    [super setUp];

    

    // Put setup code here. This method is called before the invocation of each test method in the class.

    

    // In UI tests it is usually best to stop immediately when a failure occurs.

    self.continueAfterFailure = NO;

    // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.

    [[[XCUIApplication alloc] init] launch];

    

    // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.

}


- (void)tearDown {

    // Put teardown code here. This method is called after the invocation of each test method in the class.

    [super tearDown];

}


- (void)testExample {

    // Use recording to get started writing UI tests.

    // Use XCTAssert and related functions to verify your tests produce the correct results

    

    XCUIApplication *app = [[XCUIApplication alloc] init];

    XCUIElement *hitMeButton = app.buttons[@"hit me!"];

    [hitMeButton tap];    

}


@end



Thanks
Naman
Screen Shot 2018-08-08 at 6.28.32 PM.png

Gautam

unread,
Aug 10, 2018, 6:38:23 PM8/10/18
to Naman Vishnoi, ios-accessibility
Hi Naman,

please check the GTXiLib project again, it has been updated with an Xcode project that has the example test you are looking for -> app that uses GTXiLib to verify accessibility through XCTests.

Thank you

--
You received this message because you are subscribed to the Google Groups "ios-accessibility" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibility+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ios-accessibility/2b542dc1-9d55-491f-9bfe-6046ea93fd06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gautam

unread,
Aug 10, 2018, 7:07:46 PM8/10/18
to Naman Vishnoi, ios-accessibility
Also, welcome to iOS Accessibility group!

Naman Vishnoi

unread,
Aug 13, 2018, 2:19:41 PM8/13/18
to ios-accessibility
Thanks a lot, Gautam for your reply. But unfortunately, I don't see that example in the repo. I see a folder for "TestApp" which even has a .plist but there is no .xcodeproj for the test app that I can run. I can see the view controller, AppDelegate and all, but not the .xcodeproj of the test app. Was it checked in?

The only .xcodeproj that I see is of the framework itself which has its own tests.

Naman
To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibil...@googlegroups.com.

Gautam

unread,
Aug 13, 2018, 2:43:57 PM8/13/18
to Naman Vishnoi, ios-accessibility
Hi Naman, 

the xcode project of the framework also contain the test app (and tests for it) which reference all the files including the appdelegate that you mentioned above. Please have a look I was just able to checkout the project and run them locally.

Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibility+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ios-accessibility/ca50d9c2-9348-41e2-b283-4592309589cc%40googlegroups.com.

Naman Vishnoi

unread,
Aug 13, 2018, 4:32:34 PM8/13/18
to ios-accessibility
Hi Gautam,

I am unable to find the link between the test app and the framework .xcodeproject. I don't see anything in "Target dependencies" or "Link with binaries" under build phase of the framework project. 
I apologize if I haven't been able to explain my problem properly. I haven't worked much on Xcode.

Here is what I am trying to do:
I see the test app's .xib file. I want to mess it up so that it breaks the test cases. Even if I delete it, the test cases pass. This must be because I need to rebuild the test app so that its reference is also updated (or do I need to do that manually?)
XCode doesn't open the .xib file of test app. And I don't see the .xcodeproj of test app that I can open in XCode and rebuild.

My intention is to screw the test app and see what all unit test cases fail. If I could get a clue, I'd really appreciate.

Thanks much
Naman

Gautam

unread,
Aug 13, 2018, 5:02:22 PM8/13/18
to Naman Vishnoi, ios-accessibility
Hi Naman, goto this line and file in the Xcode project and change it to:
_expectErrors = NO;

and then run tests named "FunctionalTests" (let me know if you cannot find this.) the tests will then fail.

To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibility+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ios-accessibility/5cf2f8ec-51aa-4df7-9326-5c511e44d961%40googlegroups.com.

Naman

unread,
Aug 14, 2018, 4:02:29 PM8/14/18
to ios-accessibility
Those test cases don't show up in XCode. I can see those files (Functional Tests) in the directory but not when I open the framework's xcode project. so I am not sure how to run them.

Gautam

unread,
Aug 14, 2018, 5:00:30 PM8/14/18
to Naman, ios-accessibility
Do u have the latest repo? If you can please upload a screenshot of xcode with project opened? Here is mine

To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibility+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ios-accessibility/ff933138-bee2-4efb-a6e7-349ea0e1ad06%40googlegroups.com.
ss.png

Naman

unread,
Aug 14, 2018, 5:16:24 PM8/14/18
to ios-accessibility
I deleted the repo and recloned it. I can now see both the test app and functional tests in XCode. I am able to even see the tests fail when I disable the accessibility of some elements in the test app.

Earlier, both test app and functional tests were not appearing in XCode.
I guess I might have messed something while trying different things.

But thanks a ton Gautam. You rock!

Naman

Gautam

unread,
Aug 14, 2018, 5:21:36 PM8/14/18
to Naman, ios-accessibility
👍👍

To unsubscribe from this group and stop receiving emails from it, send an email to ios-accessibility+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ios-accessibility/98dc3173-4868-4800-b0e3-24f8c2131e6f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages