diff --git a/RxExample/RxExample.xcodeproj/project.pbxproj b/RxExample/RxExample.xcodeproj/project.pbxproj index 2689e43d..5d48f844 100644 --- a/RxExample/RxExample.xcodeproj/project.pbxproj +++ b/RxExample/RxExample.xcodeproj/project.pbxproj @@ -1684,7 +1684,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = RxExample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; OTHER_SWIFT_FLAGS = "-D DEBUG -D TRACE_RESOURCES"; @@ -1726,7 +1726,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = RxExample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; OTHER_SWIFT_FLAGS = "-D RELEASE"; PRODUCT_NAME = RxExample; @@ -1740,7 +1740,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = "RxExample/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-objc_loadall"; SDKROOT = iphoneos; @@ -1751,7 +1751,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = "RxExample/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-objc_loadall"; SDKROOT = iphoneos; @@ -1812,7 +1812,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = RxExample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; MTL_ENABLE_DEBUG_INFO = NO; OTHER_SWIFT_FLAGS = "-D TRACE_RESOURCES"; PRODUCT_NAME = RxExample; @@ -1826,7 +1826,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = "RxExample/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-objc_loadall"; SDKROOT = iphoneos; diff --git a/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift b/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift index c1888e46..b4e929e9 100644 --- a/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift +++ b/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift @@ -118,9 +118,17 @@ class GitHubSignupViewController : ViewController { } >- disposeBag.addDisposable } + func dismissKeyboard(gr: UITapGestureRecognizer) { + view.endEditing(true) + } + override func viewDidLoad() { super.viewDidLoad() + let tapBackground = UITapGestureRecognizer(target: self, action: Selector("dismissKeyboard:")) + tapBackground.numberOfTouchesRequired = 1 + view.addGestureRecognizer(tapBackground) + self.disposeBag = DisposeBag() let API = self.API diff --git a/RxExample/RxExample/iOS/Main.storyboard b/RxExample/RxExample/iOS/Main.storyboard index 5ce81350..3e59fb91 100644 --- a/RxExample/RxExample/iOS/Main.storyboard +++ b/RxExample/RxExample/iOS/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -44,16 +44,19 @@ + + + - - - - + + + + diff --git a/automation-tests.sh b/automation-tests.sh index 59c15c6f..30e4d88b 100755 --- a/automation-tests.sh +++ b/automation-tests.sh @@ -1,13 +1,19 @@ #!/bin/bash -. scripts/common.sh set -e +NUM_OF_TESTS=14 CURRENT_DIR="$( dirname "${BASH_SOURCE[0]}" )" -BUILD_DIRECTORY=build +BUILD_DIRECTORY=$TMPDIR/build APP=RxExample CONFIGURATIONS="Debug Release-Tests Release" -SIMULATORS="RxSwiftTest-iPhone6-iOS8.4" +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" + +open $TMPDIR + +cd $CURRENT_DIR + +. scripts/common.sh echo "(Rx root ${CURRENT_DIR})" @@ -19,11 +25,15 @@ function runAutomation() { SIMULATOR=$1 CONFIGURATION=$2 + echo + echo + echo echo printf "${GREEN}Building example for automation ${BOLDCYAN}${SIMULATOR} - ${CONFIGURATION}${RESET}" echo - xcodebuild -workspace Rx.xcworkspace -scheme RxExample-iOS -derivedDataPath ${BUILD_DIRECTORY} -configuration ${CONFIGURATION} -destination platform='iOS Simulator',name="${SIMULATOR}" build > /dev/null + OS=`echo $SIMULATOR| cut -d'_' -f 2` + xcodebuild -workspace Rx.xcworkspace -scheme RxExample-iOS -derivedDataPath ${BUILD_DIRECTORY} -configuration ${CONFIGURATION} -destination platform='iOS Simulator',OS="${OS}",name="${SIMULATOR}" build > /dev/null echo printf "${GREEN}Quitting iOS Simulator ...${RESET}" @@ -49,8 +59,18 @@ function runAutomation() { printf "${GREEN}Running instruments ...${RESET}\n" echo - instruments -w ${SIMULATOR} -t Automation ${APP} -e UIASCRIPT $CURRENT_DIR/automation-tests/main.js #|| (open instrumentscli0.trace; exit -1;) - echo "Instruments return value" $? + instruments -w ${SIMULATOR} -t Automation ${APP} -e UIASCRIPT $CURRENT_DIR/automation-tests/main.js > $TMPDIR/output.txt #|| (open instrumentscli0.trace; exit -1;) + COUNT=`grep Pass: $TMPDIR/output.txt | wc -l` + + if [ "$COUNT" -lt "$NUM_OF_TESTS" ]; then + echo + printf "${RED}${SIMULATOR} - ${CONFIGURATION} tests do not passes${RESET}" + echo + printf "${RED}Pases ${COUNT} tests of ${NUM_OF_TESTS} ${RESET}" + echo + open ./instrumentscli0.trace; + exit; + fi popd } diff --git a/automation-tests/01_githubSignUp.js b/automation-tests/01_githubSignUp.js index ce73f2be..1a561410 100644 --- a/automation-tests/01_githubSignUp.js +++ b/automation-tests/01_githubSignUp.js @@ -1,24 +1,62 @@ -test("----- githubSignUp -----", function (target, app, check, pass) { - var window = app.mainWindow(); +test("----- githubSignUp -----", function (check, pass) { UIATarget.onAlert = function(alert){ - app.alert().buttons()["Cancel"].tap(); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().alert().buttons()["Cancel"].tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); + + pass() return false; } - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - window.textFields()[0].textFields()[0].tap();app.keyboard().typeString("rxrevolution"); - window.secureTextFields()[0].secureTextFields()[0].tap(); - app.keyboard().typeString("mypassword"); - window.secureTextFields()[1].secureTextFields()[0].tap(); - app.keyboard().typeString("mypassword"); - window.buttons()["Sign up"].tap(); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[0].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - pass() + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("rxrevolution"); // fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("r"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rx"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxr"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxre"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrev"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevo"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevol"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolu"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolut"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevoluti"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolutio"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue("rxrevolution"); + + + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("mypassword"); // fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("m"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("my"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("myp"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypa"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypas"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypass"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypassw"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypasswo"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypasswor"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[0].setValue("mypassword"); + + + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("mypassword"); // fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("m"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("my"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("myp"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypa"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypas"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypass"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypassw"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypasswo"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypasswor"); + UIATarget.localTarget().frontMostApp().mainWindow().secureTextFields()[1].setValue("mypassword"); + + UIATarget.localTarget().tap({x:14.50, y:80.00}); + UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Sign up"].tap(); }); diff --git a/automation-tests/02_searchWikipedia.js b/automation-tests/02_searchWikipedia.js index b2593e5b..ddca778e 100644 --- a/automation-tests/02_searchWikipedia.js +++ b/automation-tests/02_searchWikipedia.js @@ -1,15 +1,38 @@ -test("----- searchWikipedia -----", function (target, app, check, pass) { - var window = app.mainWindow(); +test("----- searchWikipedia -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.22, y:0.26}}); - window.searchBars()[0].searchBars()[0].tap(); - app.keyboard().typeString("functional"); - target.tap({x:325.00, y:42.33}); - app.keyboard().typeString("Yosemite"); - target.tap({x:375.33, y:43.33}); - app.navigationBar().leftButton().tap(); + var width = UIATarget.localTarget().frontMostApp().mainWindow().rect().size.width + + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].tap(); + + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("banana"); // fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("b"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("ba"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("ban"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("bana"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("banan"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("banana"); + UIATarget.localTarget().delay(2); + + UIATarget.localTarget().tap({x:width - 40, y:43}); + + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("Yosemite"); // fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Y"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yo"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yos"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yose"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosem"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemi"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemit"); + UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0].searchBars()[0].setValue("Yosemite"); + UIATarget.localTarget().delay(2); + + + UIATarget.localTarget().tap({x:width - 40, y:43}); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); pass() }); diff --git a/automation-tests/03_masterDetail.js b/automation-tests/03_masterDetail.js index dcff68d3..e8a07772 100644 --- a/automation-tests/03_masterDetail.js +++ b/automation-tests/03_masterDetail.js @@ -1,18 +1,27 @@ -test("----- masterDetail -----", function (target, app, check, pass) { - var window = app.mainWindow(); +test("----- masterDetail -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.41, y:0.32}}); - app.navigationBar().rightButton().tap(); - window.tableViews()[0].dragInsideWithOptions({startOffset:{x:0.93, y:0.58}, endOffset:{x:0.95, y:0.28}, duration:1.5}); - window.tableViews()[0].dragInsideWithOptions({startOffset:{x:0.94, y:0.58}, endOffset:{x:0.92, y:0.18}, duration:1.5}); - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.07, y:0.35}}); - window.tableViews()[0].cells()[2].tapWithOptions({tapOffset:{x:0.93, y:0.64}}); - app.navigationBar().rightButton().tap(); - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.30, y:0.23}}); - app.navigationBar().leftButton().tap(); - app.navigationBar().leftButton().tap(); + function yOffset (pixels) { + return pixels / UIATarget.localTarget().frontMostApp().mainWindow().rect().size.height + } + + + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[2].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().mainWindow().dragInsideWithOptions({startOffset:{x:0.93, y:yOffset(300)}, endOffset:{x:0.95, y:yOffset(200)}, duration:1.5}); + UIATarget.localTarget().frontMostApp().mainWindow().dragInsideWithOptions({startOffset:{x:0.93, y:yOffset(300)}, endOffset:{x:0.95, y:yOffset(100)}, duration:1.5}); + + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].buttons()[0].tap(); + + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].buttons()[2].tap(); + + UIATarget.localTarget().delay( 2 ); + + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[1].tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); pass() }); diff --git a/automation-tests/04_controlsTests.js b/automation-tests/04_controlsTests.js index 26bf5809..f03306fc 100644 --- a/automation-tests/04_controlsTests.js +++ b/automation-tests/04_controlsTests.js @@ -1,196 +1,188 @@ -UIATarget.localTarget().delay( 5 ); +// UIATarget.localTarget().delay( 15 ); -test("----- UIBarButtonItem tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UIBarButtonItem tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UIBarButtonItem Tapped"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UIBarButtonItem tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UIBarButtonItem tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.mainWindow().buttons()["TapMe"].tap(); + UIATarget.localTarget().frontMostApp().mainWindow().buttons()["TapMe"].tap(); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UIButton Tapped"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UISegmentedControl tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UISegmentedControl tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - window.segmentedControls()[0].buttons()["Second"].tap(); + UIATarget.localTarget().frontMostApp().mainWindow().segmentedControls()[0].buttons()["Second"].tap(); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UISegmentedControl value 1"; }); - window.segmentedControls()[0].buttons()["First"].tap(); + UIATarget.localTarget().frontMostApp().mainWindow().segmentedControls()[0].buttons()["First"].tap(); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UISegmentedControl value 0"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UISwitch tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UISwitch tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.mainWindow().switches()[0].setValue(0); + UIATarget.localTarget().frontMostApp().mainWindow().switches()[0].setValue(0); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UISwitch value false"; }); - app.mainWindow().switches()[0].setValue(1); + UIATarget.localTarget().frontMostApp().mainWindow().switches()[0].setValue(1); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UISwitch value true"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UITextField text -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UITextField text -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.mainWindow().textFields()[0].textFields()[0].tap(); - app.keyboard().typeString("t"); + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].textFields()[0].tap(); + // UIATarget.localTarget().frontMostApp().keyboard().typeString("t");// fails if software keyboard is disabled + UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].textFields()[0].setValue("t"); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UITextField text t"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UISlider value -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UISlider value -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.mainWindow().sliders()[0].dragToValue(0.00); + UIATarget.localTarget().frontMostApp().mainWindow().sliders()[0].dragToValue(0.00); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UISlider value 0.0"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UIDatePicker date -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UIDatePicker date -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - app.mainWindow().pickers()[0].wheels()[0].tapWithOptions({tapOffset:{x:0.49, y:0.65}}); - app.mainWindow().pickers()[0].wheels()[1].tapWithOptions({tapOffset:{x:0.35, y:0.64}}); - app.mainWindow().pickers()[0].wheels()[2].tapWithOptions({tapOffset:{x:0.46, y:0.64}}); + UIATarget.localTarget().frontMostApp().mainWindow().pickers()[0].wheels()[0].tapWithOptions({tapOffset:{x:0.49, y:0.65}}); + UIATarget.localTarget().frontMostApp().mainWindow().pickers()[0].wheels()[1].tapWithOptions({tapOffset:{x:0.35, y:0.64}}); + UIATarget.localTarget().frontMostApp().mainWindow().pickers()[0].wheels()[2].tapWithOptions({tapOffset:{x:0.46, y:0.64}}); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UIDatePicker date 1970-01-02 00:00:00 +0000"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UIActionSheet tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UIActionSheet tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - window.buttons()["Open ActionSheet"].tap(); - app.actionSheet().collectionViews()[0].cells()["OK"].buttons()["OK"].tap(); + UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Open ActionSheet"].tap(); + UIATarget.localTarget().frontMostApp().actionSheet().collectionViews()[0].cells()["OK"].buttons()["OK"].tap(); - target.delay( 2 ); + UIATarget.localTarget().delay( 2 ); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UIActionSheet didDismissWithButtonIndex 0"; }); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); }); -test("----- UIAlertView tap -----", function (target, app, check) { - var window = app.mainWindow(); +test("----- UIAlertView tap -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.31, y:0.38}}); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[3].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); - UIATarget.onAlert = function(alert){ - UIATarget.onAlert = null - app.alert().buttons()["Three"].tap(); - target.delay( 2 ); + UIATarget.localTarget().onAlert = function(alert){ + UIATarget.localTarget().onAlert = null + UIATarget.localTarget().frontMostApp().alert().buttons()["Three"].tap(); + UIATarget.localTarget().delay( 2 ); check(function () { - var textValue = window.staticTexts()["debugLabel"].value(); + var textValue = UIATarget.localTarget().frontMostApp().mainWindow().staticTexts()["debugLabel"].value(); return textValue === "UIAlertView didDismissWithButtonIndex 3"; }); - UIATarget.onAlert = function () { + UIATarget.localTarget().onAlert = function () { return false; }; - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); return false; } - window.buttons()["Open AlertView"].tap(); - target.delay( 4 ); + UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Open AlertView"].tap(); + UIATarget.localTarget().delay( 4 ); }); diff --git a/automation-tests/05_reactivePartialUpdates.js b/automation-tests/05_reactivePartialUpdates.js index 9dc55273..e7da2c19 100644 --- a/automation-tests/05_reactivePartialUpdates.js +++ b/automation-tests/05_reactivePartialUpdates.js @@ -1,18 +1,16 @@ -test("----- reactivePartialUpdates -----", function (target, app, check, pass) { - var window = app.mainWindow(); +test("----- reactivePartialUpdates -----", function (check, pass) { - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.49, y:0.70}}); - window.tableViews()[0].tapWithOptions({tapOffset:{x:0.36, y:0.56}}); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().rightButton().tap(); - app.navigationBar().leftButton().tap(); + UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[4].tapWithOptions({tapOffset:{x:0.24, y:0.20}}); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); + UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); pass() }); diff --git a/automation-tests/common.js b/automation-tests/common.js index 64592413..37bdf90b 100644 --- a/automation-tests/common.js +++ b/automation-tests/common.js @@ -1,15 +1,5 @@ - -function sleep(time) { - var target = UIATarget.localTarget(); - target.delay(time); -} - function test(testName, callback) { - var target = UIATarget.localTarget(); - var app = target.frontMostApp(); - - target.delay(1) function pass() { UIALogger.logPass( testName ); @@ -28,8 +18,9 @@ function test(testName, callback) { } } + sleep(1) UIALogger.logStart( testName ); - callback(target, app, check, pass) + callback(check, pass) } function log(string) { @@ -40,6 +31,10 @@ function debug(string) { UIALogger.logDebug(string) } +function logElement(element) { + UIALogger.logDebug(element.toString()) +} + function error(string) { UIALogger.logError(string) } @@ -47,3 +42,10 @@ function error(string) { function warning(string) { UIALogger.logWarning(string) } + +function sleep(time) { + UIATarget.localTarget().delay(time); +} + + + diff --git a/automation-tests/main.js b/automation-tests/main.js index b1a6b298..ef4aa7e9 100644 --- a/automation-tests/main.js +++ b/automation-tests/main.js @@ -5,5 +5,3 @@ #import "03_masterDetail.js" #import "04_controlsTests.js" #import "05_reactivePartialUpdates.js" - -UIALogger.logPass("All");