Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalPineapple committed Sep 24, 2024
1 parent 7457790 commit fe71ae1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
25 changes: 13 additions & 12 deletions TestHost/AccessibilityViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ @interface AccessibilityViewController_AccessibilityView : UIView
@property (nonatomic, assign) BOOL activationReturnValue;
@property (nonatomic, assign) int activationCount;

@property (nonatomic, strong) UILabel *tapLabel;
@property (nonatomic, strong) UILabel *topLabel;
@property (nonatomic, strong) UILabel *swtichLabel;
@property (nonatomic, strong) UISwitch *activationSwitch;

Expand All @@ -27,9 +27,9 @@ - (instancetype)initWithCoder:(NSCoder *)coder {

self.activationReturnValue = YES;

self.tapLabel = [[UILabel alloc] initWithFrame: CGRectZero];
self.tapLabel.text = @"Awaiting tap";
[self addSubview:self.tapLabel];
self.topLabel = [[UILabel alloc] initWithFrame: CGRectZero];
self.topLabel.text = @"Awaiting activation or tap";
[self addSubview:self.topLabel];

self.swtichLabel = [[UILabel alloc] initWithFrame: CGRectZero];
self.swtichLabel.text = @"Returns YES";
Expand Down Expand Up @@ -60,15 +60,15 @@ - (void)toggleReturnValue {

-(void)layoutSubviews {
[super layoutSubviews];
[self.tapLabel sizeToFit];
self.tapLabel.frame = CGRectMake(20,
[self.topLabel sizeToFit];
self.topLabel.frame = CGRectMake(20,
20,
self.tapLabel.frame.size.width,
self.tapLabel.frame.size.height);
self.topLabel.frame.size.width,
self.topLabel.frame.size.height);

[self.swtichLabel sizeToFit];
self.swtichLabel.frame = CGRectMake(20,
CGRectGetMaxY(self.tapLabel.frame) + 40,
CGRectGetMaxY(self.topLabel.frame) + 40,
self.swtichLabel.frame.size.width,
self.swtichLabel.frame.size.height);

Expand All @@ -81,19 +81,20 @@ -(void)layoutSubviews {
}

- (NSString *)accessibilityValue {
return self.tapLabel.text;
return self.topLabel.text;
}

- (BOOL)accessibilityActivate {
self.activationCount += 1;
self.accessibilityValue = [NSString stringWithFormat:@"Activated: %i", self.activationCount];
self.topLabel.text = [NSString stringWithFormat:@"Activated: %i", self.activationCount];
[self setNeedsLayout];
return self.activationReturnValue;
}


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
CGPoint location = [[touches anyObject] locationInView: self];
self.tapLabel.text = [NSString stringWithFormat:@"Tapped - x:%.04f, y:%.04f", location.x, location.y];
self.topLabel.text = [NSString stringWithFormat:@"Tapped - x:%.04f, y:%.04f", location.x, location.y];
[self setNeedsLayout];
}

Expand Down
5 changes: 3 additions & 2 deletions Tests/AccessibilityActivationTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ - (void)testAccessibilityActivate

- (void)testAccessibilityActiationPoint
{
UIView *view = [[viewTester usingValue: @"Awaiting tap"] waitForView];

UIView *view = [[viewTester usingValue: @"Awaiting activation or tap"] waitForView];
[view setAccessibilityActivationPoint: [view.window convertPoint:CGPointMake(25.0, 50.0) fromView:view]];
[view setNeedsLayout];

[[viewTester usingLabel: @"AccessibilityView"] tap];
[[viewTester usingValue:@"Tapped - x:25.0000, y:50.0000"] waitForView];

Expand Down

0 comments on commit fe71ae1

Please sign in to comment.