-
Notifications
You must be signed in to change notification settings - Fork 1
/
UICTextScenario.m
55 lines (44 loc) · 2.41 KB
/
UICTextScenario.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// UICTextScenario.m
// UICatalog
//
// Created by Michele Titolo on 3/5/13.
//
//
#import "UICTextScenario.h"
#import "KIFTestStep+UICAdditions.h"
#import "UIApplication-KIFAdditions.h"
#import "UIAccessibilityElement-KIFAdditions.h"
#import "KIFTestStep.h"
@implementation UICTextScenario
+ (id)scenarioTypeTextInNormalField
{
KIFTestScenario *scenario = [KIFTestScenario scenarioWithDescription:@"Test that we can open a simple alert."];
[scenario addStep:[KIFTestStep stepToScrollToItemWithAccessibilityLabel:NSLocalizedString(@"TextFieldTitle", @"")]];
[scenario addStep:[KIFTestStep stepToTapViewWithAccessibilityLabel:NSLocalizedString(@"TextFieldTitle", @"")]];
[scenario addStep:[KIFTestStep stepToWaitForTimeInterval:1 description:@"Wait for push animation"]];
[scenario addStep:[KIFTestStep stepToScrollToItemWithAccessibilityLabel:NSLocalizedString(@"NormalTextField", @"")]];
[scenario addStep:[KIFTestStep stepToEnterText:@"NSMeetup is awesome" intoViewWithAccessibilityLabel:NSLocalizedString(@"NormalTextField", @"")]];
return scenario;
}
+ (id)scenarioTypeTextInTextView
{
KIFTestScenario *scenario = [KIFTestScenario scenarioWithDescription:@"Test that we can open a simple alert."];
[scenario addStep:[KIFTestStep stepToScrollToItemWithAccessibilityLabel:NSLocalizedString(@"TextViewTitle", @"")]];
[scenario addStep:[KIFTestStep stepToTapViewWithAccessibilityLabel:NSLocalizedString(@"TextViewTitle", @"")]];
[scenario addStep:[KIFTestStep stepToWaitForTimeInterval:1 description:@"Wait for push animation"]];
// Clearing a textview is best done with setText:nil
[scenario addStep:[KIFTestStep stepWithDescription:@"Clear text in text view" executionBlock:^KIFTestStepResult(KIFTestStep *step, NSError **error) {
UIAccessibilityElement *element = [[UIApplication sharedApplication] accessibilityElementWithLabel:@"A Text View" ];
if (!element) {
return KIFTestStepResultWait;
}
UIView *view = [UIAccessibilityElement
viewContainingAccessibilityElement:element];
[(UITextField *) view setText:nil];
return KIFTestStepResultSuccess;
}]];
[scenario addStep:[KIFTestStep stepToEnterText:@"A long time ago in a galaxy far, far away..." intoViewWithAccessibilityLabel:@"A Text View" traits:UIAccessibilityTraitNone expectedResult:@""]];
return scenario;
}
@end