diff --git a/KIF Tests/AccessibilityActivationTests_ViewTestActor.m b/KIF Tests/AccessibilityActivationTests_ViewTestActor.m index c143a88f..539174f7 100644 --- a/KIF Tests/AccessibilityActivationTests_ViewTestActor.m +++ b/KIF Tests/AccessibilityActivationTests_ViewTestActor.m @@ -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 diff --git a/Sources/KIF/Classes/KIFUIViewTestActor.m b/Sources/KIF/Classes/KIFUIViewTestActor.m index 583bc7ba..6e05d6f1 100644 --- a/Sources/KIF/Classes/KIFUIViewTestActor.m +++ b/Sources/KIF/Classes/KIFUIViewTestActor.m @@ -423,6 +423,7 @@ - (void)performAccessibilityActivateWithExpectedResult:(BOOL)expectedResult; [self waitForAnimationsToFinish]; return KIFTestStepResultSuccess; } + [self waitForAnimationsToFinish]; return KIFTestStepResultFailure; }]; } diff --git a/Test Host/AccessibilityViewController.m b/Test Host/AccessibilityViewController.m index d7de2ff6..26679053 100644 --- a/Test Host/AccessibilityViewController.m +++ b/Test Host/AccessibilityViewController.m @@ -8,22 +8,40 @@ #import @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]; @@ -31,6 +49,12 @@ -(void)layoutSubviews { (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 { @@ -38,7 +62,7 @@ - (BOOL)accessibilityActivate { self.accessibilityValue = @"Activated"; self.label.text = @"Activated"; [self setNeedsLayout]; - return YES; + return self.activationReturnValue; } @end