@@ -31,6 +31,21 @@ def getBuildArguments = { ->
3131 arguments. add(" ./gradlew" )
3232 }
3333 arguments. add(" :app:installDebug" )
34+ if (project. hasProperty(" engine" )) {
35+ arguments. add(" -Pengine=${ engine} " )
36+ if (! project. hasProperty(" ns_engine" )) {
37+ arguments. add(" -Pns_engine=${ engine} " )
38+ }
39+ }
40+ if (project. hasProperty(" ns_engine" )) {
41+ arguments. add(" -Pns_engine=${ ns_engine} " )
42+ }
43+ if (project. hasProperty(" ndkDirectory" )) {
44+ arguments. add(" -PndkDirectory=${ ndkDirectory} " )
45+ }
46+ if (project. hasProperty(" ndkVersion" )) {
47+ arguments. add(" -PndkVersion=${ ndkVersion} " )
48+ }
3449 if (onlyX86) {
3550 arguments. add(" -PonlyX86" )
3651 }
@@ -50,14 +65,26 @@ task installApk(type: Exec) {
5065 }
5166}
5267
68+ task clearInstalledAppData (type : Exec ) {
69+ doFirst {
70+ println " Clearing test application data"
71+
72+ if (isWinOs) {
73+ commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator, " shell" , " pm" , " clear" , " com.tns.testapplication"
74+ } else {
75+ commandLine " adb" , runOnDeviceOrEmulator, " shell" , " pm" , " clear" , " com.tns.testapplication"
76+ }
77+ }
78+ }
79+
5380task runAdbAsRoot (type : Exec ) {
5481 doFirst {
5582 println " Running adb as root"
5683
5784 if (isWinOs) {
58- commandLine " cmd" , " /c" , " adb" , " -e " , " root"
85+ commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator , " root"
5986 } else {
60- commandLine " adb" , " -e " , " root"
87+ commandLine " adb" , runOnDeviceOrEmulator , " root"
6188 }
6289 sleep(10 * 1000 ) // wait 10s to make sure adb properly restarts, otherwise error: closed might happen on next command
6390 }
@@ -68,9 +95,9 @@ task deletePreviousResultXml(type: Exec) {
6895 println " Removing previous android_unit_test_results.xml"
6996
7097 if (isWinOs) {
71- commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator, " -e " , " shell" , " rm" , " -rf" , " /data/data/com.tns.testapplication/android_unit_test_results.xml"
98+ commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator, " shell" , " rm" , " -rf" , " /data/data/com.tns.testapplication/android_unit_test_results.xml"
7299 } else {
73- commandLine " adb" , runOnDeviceOrEmulator, " -e " , " shell" , " rm" , " -rf" , " /data/data/com.tns.testapplication/android_unit_test_results.xml"
100+ commandLine " adb" , runOnDeviceOrEmulator, " shell" , " rm" , " -rf" , " /data/data/com.tns.testapplication/android_unit_test_results.xml"
74101 }
75102 }
76103}
@@ -80,9 +107,9 @@ task startInstalledApk(type: Exec) {
80107 println " Starting test application"
81108
82109 if (isWinOs) {
83- commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator, " -e " , " shell" , " am" , " start" , " -n" , " com.tns.testapplication/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
110+ commandLine " cmd" , " /c" , " adb" , runOnDeviceOrEmulator, " shell" , " am" , " start" , " -n" , " com.tns.testapplication/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
84111 } else {
85- commandLine " adb" , runOnDeviceOrEmulator, " -e " , " shell" , " am" , " start" , " -n" , " com.tns.testapplication/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
112+ commandLine " adb" , runOnDeviceOrEmulator, " shell" , " am" , " start" , " -n" , " com.tns.testapplication/com.tns.NativeScriptActivity" , " -a" , " android.intent.action.MAIN" , " -c" , " android.intent.category.LAUNCHER"
86113 }
87114 }
88115}
@@ -133,7 +160,8 @@ task runtests {
133160runAdbAsRoot. dependsOn(waitForEmulatorToStart)
134161deletePreviousResultXml. dependsOn(runAdbAsRoot)
135162installApk. dependsOn(deletePreviousResultXml)
136- startInstalledApk. dependsOn(installApk)
163+ clearInstalledAppData. dependsOn(installApk)
164+ startInstalledApk. dependsOn(clearInstalledAppData)
137165createDistFolder. dependsOn(startInstalledApk)
138166waitForUnitTestResultFile. dependsOn(createDistFolder)
139167copyResultToDist. dependsOn(waitForUnitTestResultFile)
@@ -142,4 +170,4 @@ verifyResults.dependsOn(runtests)
142170
143171task runtestsAndVerifyResults {
144172 dependsOn verifyResults
145- }
173+ }
0 commit comments