Skip to content

Commit

Permalink
adjusting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalPineapple committed Sep 18, 2024
1 parent faa743e commit f0ef0aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion KIF Tests/AccessibilityActivationTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ - (void)afterEach

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

[[viewTester usingLabel:@"AccessibilitySwitch"] setSwitchOn:false];
[[viewTester usingLabel:@"AccessibilityView"] performAccessibilityActivateWithExpectedResult: NO];
}

@end
1 change: 1 addition & 0 deletions Sources/KIF/Classes/KIFUIViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ - (void)performAccessibilityActivateWithExpectedResult:(BOOL)expectedResult;
[self waitForAnimationsToFinish];
return KIFTestStepResultSuccess;
}
[self waitForAnimationsToFinish];
return KIFTestStepResultFailure;
}];
}
Expand Down
28 changes: 26 additions & 2 deletions Test Host/AccessibilityViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,61 @@
#import <UIKit/UIKit.h>

@interface AccessibilityViewController_AccessibilityView : UIView
@property (nonatomic, assign) BOOL activationReturnValue;

@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UISwitch *activationSwitch;
@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.activationReturnValue = YES;

self.label = [[UILabel alloc] initWithFrame: CGRectZero];
self.label.text = @"Inactive";
[self addSubview:self.label];

self.activationSwitch = [[UISwitch alloc] initWithFrame: CGRectZero];
[self.activationSwitch setOn:self.activationReturnValue];
[self.activationSwitch addTarget: self action: @selector(toggleReturnValue) forControlEvents: UIControlEventValueChanged];
self.activationSwitch.accessibilityLabel = @"AccessibilitySwitch";
[self addSubview: self.activationSwitch];

return self;
}

- (void)toggleReturnValue {
self.activationReturnValue = !self.activationReturnValue;
}

-(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);

[self.activationSwitch sizeToFit];
self.activationSwitch.frame = CGRectMake((self.frame.size.width - self.activationSwitch.frame.size.width) / 2,
CGRectGetMaxY(self.label.frame) + 10 ,
self.activationSwitch.frame.size.width,
self.activationSwitch.frame.size.width);
}

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

@end
Expand Down

0 comments on commit f0ef0aa

Please sign in to comment.