Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalPineapple committed Sep 17, 2024
1 parent ffd57e5 commit c2e68f6
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 18 deletions.
32 changes: 32 additions & 0 deletions KIF Tests/AccessibilityActivationTests_ViewTestActor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AccessibilityActivateTests_ViewTestActor.m
// KIF Tests
//
// Created by Alex Odawa on 09/07/2024.
//

#import <KIF/KIF.h>

@interface AccessibilityActivateTests_ViewTestActor : KIFTestCase
@end


@implementation AccessibilityActivateTests_ViewTestActor

- (void)beforeEach
{
[[viewTester usingLabel:@"Accessibility"] tap];
}

- (void)afterEach
{
[[[viewTester usingLabel:@"Test Suite"] usingTraits:UIAccessibilityTraitButton] tap];
}

- (void)testAccessibilityActivate
{
[[viewTester usingLabel:@"AccessibilityView"] performAccessibilityActivateWithExpectedResult:YES];
[[viewTester usingValue:@"Activated"] tryFindingView];
}

@end
8 changes: 8 additions & 0 deletions KIF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
9CC881AC1AD4CE4B002CD34C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAB0726B139719AC008AF393 /* Foundation.framework */; };
9CC881AD1AD4CE50002CD34C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CC881A21AD4CAAC002CD34C /* CoreFoundation.framework */; };
9CC967401AD4B1B600576D13 /* KIF.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CC9673F1AD4B1B600576D13 /* KIF.h */; settings = {ATTRIBUTES = (Public, ); }; };
AC2EB99A2C9A04F90082A170 /* AccessibilityActivationTests_ViewTestActor.m in Sources */ = {isa = PBXBuildFile; fileRef = AC2EB9992C9A04F90082A170 /* AccessibilityActivationTests_ViewTestActor.m */; };
AC2EB99D2C9A09790082A170 /* AccessibilityViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AC2EB99C2C9A09790082A170 /* AccessibilityViewController.m */; };
ACA242E42C3DA55400E6F1B6 /* CustomActionTests_ViewTestActor.m in Sources */ = {isa = PBXBuildFile; fileRef = ACA242E32C3DA55400E6F1B6 /* CustomActionTests_ViewTestActor.m */; };
ACA242E72C3DB47400E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = ACA242E52C3DB46A00E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.m */; };
ACA242E92C3DB4EA00E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = ACA242E82C3DB4B000E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -432,6 +434,8 @@
9CC9673F1AD4B1B600576D13 /* KIF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KIF.h; sourceTree = "<group>"; };
AAB0726B139719AC008AF393 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
AAB072B413971AEA008AF393 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
AC2EB9992C9A04F90082A170 /* AccessibilityActivationTests_ViewTestActor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccessibilityActivationTests_ViewTestActor.m; sourceTree = "<group>"; };
AC2EB99C2C9A09790082A170 /* AccessibilityViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccessibilityViewController.m; sourceTree = "<group>"; };
ACA242E32C3DA55400E6F1B6 /* CustomActionTests_ViewTestActor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomActionTests_ViewTestActor.m; sourceTree = "<group>"; };
ACA242E52C3DB46A00E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIAccessibilityCustomAction+KIFAdditions.m"; sourceTree = "<group>"; };
ACA242E82C3DB4B000E6F1B6 /* UIAccessibilityCustomAction+KIFAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIAccessibilityCustomAction+KIFAdditions.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -824,6 +828,7 @@
EB60ECFC177F9031005A041A /* AppDelegate.m */,
EB60ECFD177F9031005A041A /* ShowHideViewController.m */,
EB9FB42617A5BACB00DDF160 /* GestureViewController.m */,
AC2EB99C2C9A09790082A170 /* AccessibilityViewController.m */,
EB60ECFE177F9032005A041A /* TapViewController.m */,
EB60ECFF177F9032005A041A /* TestSuiteViewController.m */,
EA0F25491829839E006FF825 /* CollectionViewController.m */,
Expand Down Expand Up @@ -933,6 +938,7 @@
FA8A3C601A77320000206350 /* SystemAlertTests_ViewTestActor.m */,
8E654FC329D79BD8007F7811 /* OffscreenTests_ViewTestActor.m */,
ACA242E32C3DA55400E6F1B6 /* CustomActionTests_ViewTestActor.m */,
AC2EB9992C9A04F90082A170 /* AccessibilityActivationTests_ViewTestActor.m */,
);
name = "KIFUIViewTestActor Tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -1405,6 +1411,7 @@
FA8A3C5D1A772CD100206350 /* WaitForAbscenceTests_ViewTestActor.m in Sources */,
FA8A3C5B1A77281900206350 /* WebViewTests_ViewTestActor.m in Sources */,
EABD46B11857A0F300A5F081 /* SearchFieldTests.m in Sources */,
AC2EB99A2C9A04F90082A170 /* AccessibilityActivationTests_ViewTestActor.m in Sources */,
EABD46B21857A0F300A5F081 /* CascadingFailureTests.m in Sources */,
EABD46B31857A0F300A5F081 /* CompositionTests.m in Sources */,
CD4E91F01F479A8C005D530C /* CustomPickerTests.m in Sources */,
Expand Down Expand Up @@ -1475,6 +1482,7 @@
EB60ED02177F9032005A041A /* TapViewController.m in Sources */,
2CDEE1CB181DBED200DF6E63 /* PickerController.m in Sources */,
EB60ED03177F9032005A041A /* TestSuiteViewController.m in Sources */,
AC2EB99D2C9A09790082A170 /* AccessibilityViewController.m in Sources */,
D9EA274318F05A6700D87E57 /* ScrollViewController.m in Sources */,
8EAA1EE229D3AF7A008F6029 /* OffscreenViewController.m in Sources */,
3812FB611A1212A700335733 /* AnimationViewController.m in Sources */,
Expand Down
56 changes: 56 additions & 0 deletions Test Host/AccessibilityViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// AccessibilityViewController.m
// Test Host
//
// Created by Alex Odawa on 17/09/2024.
//

#import <UIKit/UIKit.h>

@interface AccessibilityViewController_AccessibilityView : UIView
@property (nonatomic, strong) UILabel *label;
@end


@implementation AccessibilityViewController_AccessibilityView
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
self.isAccessibilityElement = YES;
self.accessibilityLabel = @"AccessibilityView";
self.backgroundColor = [UIColor systemPinkColor];
self.label = [[UILabel alloc] initWithFrame:CGRectZero];
self.label.text = @"Inactive";
[self addSubview:self.label];
return self;
}

-(void)layoutSubviews {
[super layoutSubviews];
[self.label sizeToFit];
self.label.frame = CGRectMake(self.frame.size.width - self.label.frame.size.width / 2,
self.frame.size.height - self.label.frame.size.height / 2,
self.label.frame.size.width,
self.label.frame.size.height);
}

- (BOOL)accessibilityActivate {
self.backgroundColor = [UIColor systemTealColor];
self.accessibilityValue = @"Activated";
self.label.text = @"Activated";
return YES;
}

@end

@interface AccessibilityViewController : UIViewController

@end

@implementation AccessibilityViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

@end
Loading

0 comments on commit c2e68f6

Please sign in to comment.