Skip to content

Commit bbda583

Browse files
committed
little improvements in automation tests
- more robust testing - tests stop on failure - now allow iOS non latest
1 parent 2faddc6 commit bbda583

File tree

11 files changed

+241
-150
lines changed

11 files changed

+241
-150
lines changed

RxExample/RxExample.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@
16841684
GCC_WARN_UNUSED_FUNCTION = YES;
16851685
GCC_WARN_UNUSED_VARIABLE = YES;
16861686
INFOPLIST_FILE = RxExample/Info.plist;
1687-
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
1687+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
16881688
MTL_ENABLE_DEBUG_INFO = YES;
16891689
ONLY_ACTIVE_ARCH = YES;
16901690
OTHER_SWIFT_FLAGS = "-D DEBUG -D TRACE_RESOURCES";
@@ -1726,7 +1726,7 @@
17261726
GCC_WARN_UNUSED_FUNCTION = YES;
17271727
GCC_WARN_UNUSED_VARIABLE = YES;
17281728
INFOPLIST_FILE = RxExample/Info.plist;
1729-
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
1729+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
17301730
MTL_ENABLE_DEBUG_INFO = NO;
17311731
OTHER_SWIFT_FLAGS = "-D RELEASE";
17321732
PRODUCT_NAME = RxExample;
@@ -1740,7 +1740,7 @@
17401740
isa = XCBuildConfiguration;
17411741
buildSettings = {
17421742
INFOPLIST_FILE = "RxExample/Info-iOS.plist";
1743-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
1743+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
17441744
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
17451745
OTHER_LDFLAGS = "-objc_loadall";
17461746
SDKROOT = iphoneos;
@@ -1751,7 +1751,7 @@
17511751
isa = XCBuildConfiguration;
17521752
buildSettings = {
17531753
INFOPLIST_FILE = "RxExample/Info-iOS.plist";
1754-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
1754+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
17551755
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
17561756
OTHER_LDFLAGS = "-objc_loadall";
17571757
SDKROOT = iphoneos;
@@ -1812,7 +1812,7 @@
18121812
GCC_WARN_UNUSED_FUNCTION = YES;
18131813
GCC_WARN_UNUSED_VARIABLE = YES;
18141814
INFOPLIST_FILE = RxExample/Info.plist;
1815-
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
1815+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
18161816
MTL_ENABLE_DEBUG_INFO = NO;
18171817
OTHER_SWIFT_FLAGS = "-D TRACE_RESOURCES";
18181818
PRODUCT_NAME = RxExample;
@@ -1826,7 +1826,7 @@
18261826
isa = XCBuildConfiguration;
18271827
buildSettings = {
18281828
INFOPLIST_FILE = "RxExample/Info-iOS.plist";
1829-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
1829+
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
18301830
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
18311831
OTHER_LDFLAGS = "-objc_loadall";
18321832
SDKROOT = iphoneos;

RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,17 @@ class GitHubSignupViewController : ViewController {
118118
} >- disposeBag.addDisposable
119119
}
120120

121+
func dismissKeyboard(gr: UITapGestureRecognizer) {
122+
view.endEditing(true)
123+
}
124+
121125
override func viewDidLoad() {
122126
super.viewDidLoad()
123127

128+
let tapBackground = UITapGestureRecognizer(target: self, action: Selector("dismissKeyboard:"))
129+
tapBackground.numberOfTouchesRequired = 1
130+
view.addGestureRecognizer(tapBackground)
131+
124132
self.disposeBag = DisposeBag()
125133

126134
let API = self.API

RxExample/RxExample/iOS/Main.storyboard

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="E5v-jn-n2n">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14F19a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="E5v-jn-n2n">
33
<dependencies>
44
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
55
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
@@ -44,16 +44,19 @@
4444
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Pbx-dk-7Jc" id="gCd-uh-Y2z">
4545
<autoresizingMask key="autoresizingMask"/>
4646
</tableViewCellContentView>
47+
<accessibility key="accessibilityConfiguration">
48+
<bool key="isElement" value="YES"/>
49+
</accessibility>
4750
</tableViewCell>
4851
</prototypes>
4952
</tableView>
5053
</subviews>
5154
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
5255
<constraints>
53-
<constraint firstItem="LL7-L6-PAN" firstAttribute="top" secondItem="Ykd-ED-72a" secondAttribute="bottom" id="AW4-VN-deD"/>
54-
<constraint firstAttribute="trailingMargin" secondItem="Ykd-ED-72a" secondAttribute="trailing" constant="-16" id="HHf-o6-Nhf"/>
55-
<constraint firstItem="Ykd-ED-72a" firstAttribute="leading" secondItem="SVj-VH-wgI" secondAttribute="leadingMargin" constant="-16" id="ScA-bo-tHw"/>
56-
<constraint firstItem="Ykd-ED-72a" firstAttribute="top" secondItem="SVj-VH-wgI" secondAttribute="topMargin" id="iOO-4F-fTM"/>
56+
<constraint firstItem="Ykd-ED-72a" firstAttribute="bottom" secondItem="LL7-L6-PAN" secondAttribute="top" id="1l8-Du-X1S"/>
57+
<constraint firstAttribute="trailing" secondItem="Ykd-ED-72a" secondAttribute="trailing" id="2jg-pR-iuD"/>
58+
<constraint firstItem="Ykd-ED-72a" firstAttribute="top" secondItem="SVj-VH-wgI" secondAttribute="top" id="Q5a-et-oZ4"/>
59+
<constraint firstItem="Ykd-ED-72a" firstAttribute="leading" secondItem="SVj-VH-wgI" secondAttribute="leading" id="oly-BI-P6E"/>
5760
</constraints>
5861
</view>
5962
<navigationItem key="navigationItem" id="2Vl-fK-l12"/>

automation-tests.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/bin/bash
22

3-
. scripts/common.sh
43

54
set -e
5+
NUM_OF_TESTS=14
66
CURRENT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
7-
BUILD_DIRECTORY=build
7+
BUILD_DIRECTORY=$TMPDIR/build
88
APP=RxExample
99
CONFIGURATIONS="Debug Release-Tests Release"
10-
SIMULATORS="RxSwiftTest-iPhone6-iOS8.4"
10+
SIMULATORS="RxSwiftTest-iPhone4s-iOS_8.4 RxSwiftTest-iPhone5-iOS_8.4 RxSwiftTest-iPhone5s-iOS_8.4 RxSwiftTest-iPhone6-iOS_8.4 RxSwiftTest-iPhone6Plus-iOS_8.4 RxSwiftTest-iPhone4s-iOS_8.1 RxSwiftTest-iPhone5-iOS_8.1 RxSwiftTest-iPhone5s-iOS_8.1 RxSwiftTest-iPhone6-iOS_8.1 RxSwiftTest-iPhone6Plus-iOS_8.1"
11+
12+
open $TMPDIR
13+
14+
cd $CURRENT_DIR
15+
16+
. scripts/common.sh
1117

1218
echo "(Rx root ${CURRENT_DIR})"
1319

@@ -19,11 +25,15 @@ function runAutomation() {
1925
SIMULATOR=$1
2026
CONFIGURATION=$2
2127

28+
echo
29+
echo
30+
echo
2231
echo
2332
printf "${GREEN}Building example for automation ${BOLDCYAN}${SIMULATOR} - ${CONFIGURATION}${RESET}"
2433
echo
2534

26-
xcodebuild -workspace Rx.xcworkspace -scheme RxExample-iOS -derivedDataPath ${BUILD_DIRECTORY} -configuration ${CONFIGURATION} -destination platform='iOS Simulator',name="${SIMULATOR}" build > /dev/null
35+
OS=`echo $SIMULATOR| cut -d'_' -f 2`
36+
xcodebuild -workspace Rx.xcworkspace -scheme RxExample-iOS -derivedDataPath ${BUILD_DIRECTORY} -configuration ${CONFIGURATION} -destination platform='iOS Simulator',OS="${OS}",name="${SIMULATOR}" build > /dev/null
2737

2838
echo
2939
printf "${GREEN}Quitting iOS Simulator ...${RESET}"
@@ -49,8 +59,18 @@ function runAutomation() {
4959
printf "${GREEN}Running instruments ...${RESET}\n"
5060
echo
5161

52-
instruments -w ${SIMULATOR} -t Automation ${APP} -e UIASCRIPT $CURRENT_DIR/automation-tests/main.js #|| (open instrumentscli0.trace; exit -1;)
53-
echo "Instruments return value" $?
62+
instruments -w ${SIMULATOR} -t Automation ${APP} -e UIASCRIPT $CURRENT_DIR/automation-tests/main.js > $TMPDIR/output.txt #|| (open instrumentscli0.trace; exit -1;)
63+
COUNT=`grep Pass: $TMPDIR/output.txt | wc -l`
64+
65+
if [ "$COUNT" -lt "$NUM_OF_TESTS" ]; then
66+
echo
67+
printf "${RED}${SIMULATOR} - ${CONFIGURATION} tests do not passes${RESET}"
68+
echo
69+
printf "${RED}Pases ${COUNT} tests of ${NUM_OF_TESTS} ${RESET}"
70+
echo
71+
open ./instrumentscli0.trace;
72+
exit;
73+
fi
5474
popd
5575
}
5676

automation-tests/01_githubSignUp.js

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,62 @@
11

22

3-
test("----- githubSignUp -----", function (target, app, check, pass) {
4-
var window = app.mainWindow();
3+
test("----- githubSignUp -----", function (check, pass) {
54

65
UIATarget.onAlert = function(alert){
7-
app.alert().buttons()["Cancel"].tap();
8-
app.navigationBar().leftButton().tap();
6+
UIATarget.localTarget().frontMostApp().alert().buttons()["Cancel"].tap();
7+
UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap();
8+
9+
pass()
910
return false;
1011
}
1112

12-
window.tableViews()[0].tapWithOptions({tapOffset:{x:0.24, y:0.20}});
13-
window.textFields()[0].textFields()[0].tap();app.keyboard().typeString("rxrevolution");
14-
window.secureTextFields()[0].secureTextFields()[0].tap();
15-
app.keyboard().typeString("mypassword");
16-
window.secureTextFields()[1].secureTextFields()[0].tap();
17-
app.keyboard().typeString("mypassword");
18-
window.buttons()["Sign up"].tap();
19-
app.navigationBar().leftButton().tap();
20-
21-
pass()
13+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[0].tapWithOptions({tapOffset:{x:0.24, y:0.20}});
14+
15+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].tap();
16+
// UIATarget.localTarget().frontMostApp().keyboard().typeString("rxrevolution"); // fails if software keyboard is disabled
17+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("r");
18+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rx");
19+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxr");
20+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxre");
21+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrev");
22+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevo");
23+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevol");
24+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolu");
25+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolut");
26+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevoluti");
27+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolutio");
28+
UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolution");
29+
30+
31+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].tap();
32+
// UIATarget.localTarget().frontMostApp().keyboard().typeString("mypassword"); // fails if software keyboard is disabled
33+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("m");
34+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("my");
35+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("myp");
36+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypa");
37+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypas");
38+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypass");
39+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypassw");
40+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypasswo");
41+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypasswor");
42+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypassword");
43+
44+
45+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].tap();
46+
// UIATarget.localTarget().frontMostApp().keyboard().typeString("mypassword"); // fails if software keyboard is disabled
47+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("m");
48+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("my");
49+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("myp");
50+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypa");
51+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypas");
52+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypass");
53+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypassw");
54+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypasswo");
55+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypasswor");
56+
UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypassword");
57+
58+
UIATarget.localTarget().tap({x:14.50, y:80.00});
59+
UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Sign up"].tap();
2260
});
2361

2462

automation-tests/02_searchWikipedia.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
11

22

3-
test("----- searchWikipedia -----", function (target, app, check, pass) {
4-
var window = app.mainWindow();
5-
6-
window.tableViews()[0].tapWithOptions({tapOffset:{x:0.22, y:0.26}});
7-
window.searchBars()[0].searchBars()[0].tap();
8-
app.keyboard().typeString("functional");
9-
target.tap({x:325.00, y:42.33});
10-
app.keyboard().typeString("Yosemite");
11-
target.tap({x:375.33, y:43.33});
12-
app.navigationBar().leftButton().tap();
3+
test("----- searchWikipedia -----", function (check, pass) {
4+
5+
var width = UIATarget.localTarget().frontMostApp().mainWindow().rect().size.width
6+
7+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].tap();
8+
9+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].tap();
10+
// UIATarget.localTarget().frontMostApp().keyboard().typeString("banana"); // fails if software keyboard is disabled
11+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("b");
12+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("ba");
13+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("ban");
14+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("bana");
15+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("banan");
16+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("banana");
17+
UIATarget.localTarget().delay(2);
18+
19+
UIATarget.localTarget().tap({x:width - 40, y:43});
20+
21+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].tap();
22+
// UIATarget.localTarget().frontMostApp().keyboard().typeString("Yosemite"); // fails if software keyboard is disabled
23+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Y");
24+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yo");
25+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yos");
26+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yose");
27+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosem");
28+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemi");
29+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemit");
30+
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemite");
31+
UIATarget.localTarget().delay(2);
32+
33+
34+
UIATarget.localTarget().tap({x:width - 40, y:43});
35+
UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap();
1336

1437
pass()
1538
});

automation-tests/03_masterDetail.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11

22

3-
test("----- masterDetail -----", function (target, app, check, pass) {
4-
var window = app.mainWindow();
5-
6-
window.tableViews()[0].tapWithOptions({tapOffset:{x:0.41, y:0.32}});
7-
app.navigationBar().rightButton().tap();
8-
window.tableViews()[0].dragInsideWithOptions({startOffset:{x:0.93, y:0.58}, endOffset:{x:0.95, y:0.28}, duration:1.5});
9-
window.tableViews()[0].dragInsideWithOptions({startOffset:{x:0.94, y:0.58}, endOffset:{x:0.92, y:0.18}, duration:1.5});
10-
window.tableViews()[0].tapWithOptions({tapOffset:{x:0.07, y:0.35}});
11-
window.tableViews()[0].cells()[2].tapWithOptions({tapOffset:{x:0.93, y:0.64}});
12-
app.navigationBar().rightButton().tap();
13-
window.tableViews()[0].tapWithOptions({tapOffset:{x:0.30, y:0.23}});
14-
app.navigationBar().leftButton().tap();
15-
app.navigationBar().leftButton().tap();
3+
test("----- masterDetail -----", function (check, pass) {
4+
5+
function yOffset (pixels) {
6+
return pixels / UIATarget.localTarget().frontMostApp().mainWindow().rect().size.height
7+
}
8+
9+
10+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[2].tapWithOptions({tapOffset:{x:0.24, y:0.20}});
11+
UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap();
12+
UIATarget.localTarget().frontMostApp().mainWindow().dragInsideWithOptions({startOffset:{x:0.93, y:yOffset(300)}, endOffset:{x:0.95, y:yOffset(200)}, duration:1.5});
13+
UIATarget.localTarget().frontMostApp().mainWindow().dragInsideWithOptions({startOffset:{x:0.93, y:yOffset(300)}, endOffset:{x:0.95, y:yOffset(100)}, duration:1.5});
14+
15+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].buttons()[0].tap();
16+
17+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].buttons()[2].tap();
18+
19+
UIATarget.localTarget().delay( 2 );
20+
21+
UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap();
22+
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].tap();
23+
UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap();
24+
UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap();
1625

1726
pass()
1827
});

0 commit comments

Comments
 (0)