UITester: fix broken UI tests

This commit is contained in:
Gautier Pelloux-Prayer 2015-12-23 11:40:02 +01:00
parent 35f7c47fd8
commit e41aa8e1a5
6 changed files with 22 additions and 13 deletions

View file

@ -59,8 +59,9 @@
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="9" contentMode="left" text="99" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="7" id="ZXq-Do-7Ua" userLabel="unreadCountLabel">
<rect key="frame" x="0.0" y="0.0" width="21" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Missed message(s)">
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" none="YES"/>
<bool key="isElement" value="NO"/>
</accessibility>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>

View file

@ -33,7 +33,6 @@
@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
@property (nonatomic, strong) IBOutlet UILabel* chatContentLabel;
@property(weak, nonatomic) IBOutlet UILabel *chatLatestTimeLabel;
@property(weak, nonatomic) IBOutlet UIIconButton *unreadCountButton;
@property(weak, nonatomic) IBOutlet UIBouncingView *unreadCountView;
@property(weak, nonatomic) IBOutlet UILabel *unreadCountLabel;

View file

@ -52,10 +52,9 @@
- (NSString *)accessibilityValue {
if (_chatContentLabel.text) {
return [NSString stringWithFormat:@"%@, %@ (%li)", _addressLabel.text, _chatContentLabel.text,
(long)[_unreadCountButton.titleLabel.text integerValue]];
(long)[_unreadCountLabel.text integerValue]];
} else {
return [NSString
stringWithFormat:@"%@ (%li)", _addressLabel.text, (long)[_unreadCountButton.titleLabel.text integerValue]];
return [NSString stringWithFormat:@"%@ (%li)", _addressLabel.text, (long)[_unreadCountLabel.text integerValue]];
}
}

View file

@ -23,6 +23,9 @@
- (void)afterEach {
[super afterEach];
[LinphoneManager.instance removeAllAccounts];
if ([tester tryFindingTappableViewWithAccessibilityLabel:@"Cancel" error:nil]) {
[tester tapViewWithAccessibilityLabel:@"Cancel"];
}
[tester tapViewWithAccessibilityLabel:@"Dialer"];
}
@ -42,6 +45,7 @@
[tester enterText:[self me] intoViewWithAccessibilityLabel:@"Username"];
[tester enterText:[self me] intoViewWithAccessibilityLabel:@"Password"];
[tester clearTextFromViewWithAccessibilityLabel:@"Domain"];
[tester enterText:[self accountDomain] intoViewWithAccessibilityLabel:@"Domain"];
[tester tapViewWithAccessibilityLabel:protocol];
@ -101,8 +105,7 @@
if (reason == nil) {
[tester fail];
} else {
[tester tapViewWithAccessibilityLabel:@"OK"]; // alertview
[tester tapViewWithAccessibilityLabel:@"Dialer"];
[tester tapViewWithAccessibilityLabel:@"Continue"];
}
} else {
[tester fail];

View file

@ -87,12 +87,17 @@
[tester choosePhotoInAlbum:@"Camera Roll" atRow:2 column:2 + (messagesCount % 2)];
// wait for the quality popup to show up
[tester waitForTimeInterval:1];
UIAccessibilityElement *element =
[[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *element) {
return [element.accessibilityLabel containsString:quality];
}];
UIAccessibilityElement *element = nil;
float timeout = 10;
while (!element && timeout > 0.f) {
[tester waitForTimeInterval:.5];
timeout -= .5f;
element =
[[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *e) {
return [e.accessibilityLabel containsString:quality];
}];
}
XCTAssertNotNil(element);
[tester tapViewWithAccessibilityLabel:element.accessibilityLabel];
}

View file

@ -9,6 +9,8 @@
#import <KIF/KIF.h>
#import <KIF/UIApplication-KIFAdditions.h>
#import "Utils.h"
@interface LinphoneTestCase : KIFTestCase
@property BOOL invalidAccountSet;