Commit 1714137f authored by Aneta Steimarova's avatar Aneta Steimarova

#691 Added installing Tablexia into Android and command for running test

parent 23edaa4d
......@@ -218,6 +218,11 @@ task copyAndroidNatives() {
}
task run(type: Exec) {
def adb = doAndroidSettings()
commandLine "$adb", 'shell', 'am', 'start', '-n', 'cz.nic.tablexia.android/cz.nic.tablexia.android.AndroidLauncher'
}
def doAndroidSettings() {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
......@@ -235,8 +240,7 @@ task run(type: Exec) {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'cz.nic.tablexia.android/cz.nic.tablexia.android.AndroidLauncher'
return path + "/platform-tools/adb"
}
// sets up the Android Idea project, using the old Ant based build.
......@@ -263,50 +267,38 @@ idea {
}
//TODO make android iTest runner like in desktop->build.gradle
/*task runAndroidITestBundle(type: Exec) {
int testsCount = 0;
int successfulTestsCount = 0;
task runAndroidITestBundle {
doLast{
int testsCount = 0;
int successfulTestsCount = 0;
def iTestOutputPath = "${libsDir}/iTest_results/"
println "${libsDir}"
def iTestOutputFile = new File(iTestOutputPath)
if (iTestOutputFile.exists()) {
println "[iTest] REMOVING OLD iTest OUTPUT DIRECTORY"
iTestOutputFile.deleteDir()
}
println "[iTest] CREATING NEW iTest OUTPUT DIRECTORY"
def iTestOutputFile = new File("${project(':android').projectDir}/build/outputs/apk/iTest_results/")
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
def adb = doAndroidSettings()
println "[iTest] INSTALLING Tablexia (iTest) into connected Android device"
exec {
commandLine "$adb", 'install', '-r', "${project(':android').projectDir}/build/outputs/apk/" + "Tablexia (androidITest-gradle)-iTest-" + "$tablexiaVersionName" + ".apk"
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
println "[iTest] INSTALLING Tablexia (iTest) into connected Android device complete"
new File("${project(':itest').projectDir}/iTestBundle.txt").eachLine { iTestName ->
testsCount++
exec {
commandLine "$adb", 'shell', 'am', 'start', '-a', "android.intent.action.MAIN", '-n', "cz.nic.tablexia.itest/cz.nic.tablexia.android.AndroidITestLauncher", '-e', "testClassName", "NewUserScenario"
}
println "[iTest] Test NewUserScenario finished."
}
} else {
path = "$System.env.ANDROID_HOME"
println "[iTest] $testsCount" + " tests were found in iTestBundle.txt"
}
def adb = path + "/platform-tools/adb"
new File("${project(':itest').projectDir}/iTestBundle.txt").eachLine { iTestName ->
testsCount++
println "[iTest] STARTING TEST: " + iTestName
commandLine "$adb", 'shell', 'am', 'start', '-a', 'android.intent.action.MAIN', '-n', 'cz.nic.tablexia.itest/cz.nic.tablexia.android.AndroidITestLauncher', '-e', 'testClassName', iTestName
//TODO wait until test finished - shell: "$(adb shell ps | grep tablexia.itest | wc -l)" != "1"
commandLine "$adb", 'pull', '/sdcard/$testDir $tablexia/$android'
commandLine "$adb", 'shell', 'rm', '-r', '/sdcard/$testDir'
println "[iTest] TEST: " + iTestName + " FINISHED"
}*/
/*println "[iTest] RUNNING Android tests"
workingDir "${project(':itest').projectDir}"
commandLine "./runAndroidITests.sh"*/
//TODO make counting files work
/*iTestOutputFile.traverse(type : FileType.FILES, nameFilter: ~/OK_.*\.log/) { iTestLog ->
successfulTestsCount++;
}*/
/* if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: \'${iTestOutputPath}\'")
}*/
// if (testsCount != successfulTestsCount) throw new GradleException("Failed to complete all iTests! Check iTest log files in: \'${iTestOutputPath}\'")
}
\ No newline at end of file
TestScenarioHallOfFameRobberyTrophies
TestScenarioHallOfFamePursuitTrophies
TestScenarioHallOfFameKidnappingTrophies
TestScenarioHallOfFameNightWatchTrophies
TestScenarioHallOfFameShootingRangeTrophies
TestScenarioHallOfFameInTheDarknessTrophies
TestScenarioHallOfFameCrimeSceneTrophies
TestScenarioHallOfFameRunesTrophies
TestScenarioHeapOfTrophies
NewUserScenario
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment