mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
fix path compatibility for any os
This commit is contained in:
parent
a5c0aebbe7
commit
41faf249c9
2 changed files with 36 additions and 33 deletions
|
|
@ -91,6 +91,7 @@ android {
|
|||
//testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testOptions {
|
||||
//execution 'ANDROIDX_TEST_ORCHESTRATOR'
|
||||
animationsDisabled = true
|
||||
}
|
||||
}
|
||||
|
|
@ -268,13 +269,14 @@ dependencies {
|
|||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
||||
|
||||
// UITests dependencies
|
||||
debugImplementation 'androidx.test:runner:1.1.3'
|
||||
debugImplementation 'androidx.test:core:1.1.3'
|
||||
debugImplementation 'androidx.test.ext:junit-ktx:1.1.3'
|
||||
debugImplementation 'androidx.test:runner:1.5.1'
|
||||
debugImplementation 'androidx.test:core:1.5.0'
|
||||
debugImplementation 'androidx.test.ext:junit-ktx:1.1.4'
|
||||
|
||||
debugImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
debugImplementation 'androidx.test.espresso:espresso-idling-resource:3.4.0'
|
||||
debugImplementation 'androidx.test.espresso:espresso-core:3.5.0'
|
||||
debugImplementation 'androidx.test.espresso:espresso-idling-resource:3.5.0'
|
||||
debugImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
//androidTestUtil 'androidx.test:orchestrator:1.4.2'
|
||||
}
|
||||
|
||||
task generateContactsXml(type: Copy) {
|
||||
|
|
@ -306,8 +308,8 @@ if (crashlyticsAvailable) {
|
|||
|
||||
// screenshots ui tests
|
||||
|
||||
def reportsDirectory = "$buildDir/reports/androidTests/connected"
|
||||
def screenshotDirectory = "$reportsDirectory/screenshots"
|
||||
def reportsDirectory = new File(buildDir,"reports${File.separator}androidTests${File.separator}connected").absolutePath
|
||||
def screenshotDirectory = new File(reportsDirectory,"screenshots").absolutePath
|
||||
|
||||
def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
||||
doFirst {
|
||||
|
|
@ -315,7 +317,7 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
def failureScreenshotsDirectory = new File(reportsDirectory, 'failures')
|
||||
|
||||
if (!failureScreenshotsDirectory.exists()) {
|
||||
println 'Could not find screenshot failures. Skipping...'
|
||||
println "Could not find screenshot failures at $failureScreenshotsDirectory Skipping..."
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -328,10 +330,10 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
failedTestFile.eachFile { failedTestCase ->
|
||||
def failedTestCaseDescription = failedTestCase.name
|
||||
def pt1 = failedTestCaseDescription.indexOf(".")
|
||||
def line = failedTestCaseDescription.substring(0,pt1)
|
||||
def pt2 = failedTestCaseDescription.indexOf(".",pt1)
|
||||
def name = failedTestCaseDescription.substring(pt1,pt2)
|
||||
def pt3 = failedTestCaseDescription.indexOf(".",pt2)
|
||||
def line = failedTestCaseDescription.substring(0, pt1)
|
||||
def pt2 = failedTestCaseDescription.indexOf(".", pt1)
|
||||
def name = failedTestCaseDescription.substring(pt1, pt2)
|
||||
def pt3 = failedTestCaseDescription.indexOf(".", pt2)
|
||||
if (pt3 != -1) name += " (${failedTestCaseDescription.substring(pt3)})"
|
||||
|
||||
def failedTestClassJunitReportFile = new File(reportsDirectory, "${failedTestClassName}.html")
|
||||
|
|
@ -348,7 +350,7 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
|
||||
if (tab0Index != -1) {
|
||||
def newtab0 = "<a href=\"#tab0\">Failed tests</a>\n</li>\n<li>\n<a href=\"#tab1\">Tests</a>\n</li>\n</ul>\n<div id=\"tab0\" class=\"tab\">\n<h2>Failed tests</h2>\n</div>\n<div id=\"tab1\" class=\"tab\">"
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace(tab0,newtab0)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace(tab0, newtab0)
|
||||
}
|
||||
|
||||
def failedTest = "<h3 class=\"failures\">${failedTestName}</h3>"
|
||||
|
|
@ -358,27 +360,27 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
if (failedTestIndex == -1) {
|
||||
def newtestDiv = "<div class=\"test\">\n<a name=\"${failedTestName}\"></a>\n${failedTest}\n<span class=\"code\">\n<pre>\n</pre>\n</span>\n</div>"
|
||||
def endDiv = "</div>\n<div id=\"tab1\" class=\"tab\">"
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace(endDiv,newtestDiv+endDiv)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace("<td>${failedTestName}</td>\n<td class=\"success\">passed","<td>${failedTestName}</td>\n<td class=\"failures\">failed")
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace(endDiv, newtestDiv + endDiv)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace("<td>${failedTestName}</td>\n<td class=\"success\">passed", "<td>${failedTestName}</td>\n<td class=\"failures\">failed")
|
||||
|
||||
def totalCounterStr = "id=\"tests\">\n<div class=\"counter\">"
|
||||
def totalCounterStart = failedTestJunitReportContent.indexOf(totalCounterStr) + totalCounterStr.length()
|
||||
def totalCounterEnd = failedTestJunitReportContent.indexOf("</div>",totalCounterStart)
|
||||
def totalCounterEnd = failedTestJunitReportContent.indexOf("</div>", totalCounterStart)
|
||||
|
||||
def failureCounterStr = "id=\"failures\">\n<div class=\"counter\">"
|
||||
def failureCounterStart = failedTestJunitReportContent.indexOf(failureCounterStr,totalCounterEnd) + failureCounterStr.length()
|
||||
def failureCounterEnd = failedTestJunitReportContent.indexOf("</div>",failureCounterStart)
|
||||
def failureCounterStart = failedTestJunitReportContent.indexOf(failureCounterStr, totalCounterEnd) + failureCounterStr.length()
|
||||
def failureCounterEnd = failedTestJunitReportContent.indexOf("</div>", failureCounterStart)
|
||||
|
||||
def percentInfoStr = "id=\"successRate\">\n<div class=\"percent\">"
|
||||
def percentInfoStart = failedTestJunitReportContent.indexOf(percentInfoStr,failureCounterEnd) + percentInfoStr.length()
|
||||
def percentInfoEnd = failedTestJunitReportContent.indexOf("%</div>",percentInfoStart)
|
||||
def percentInfoStart = failedTestJunitReportContent.indexOf(percentInfoStr, failureCounterEnd) + percentInfoStr.length()
|
||||
def percentInfoEnd = failedTestJunitReportContent.indexOf("%</div>", percentInfoStart)
|
||||
|
||||
def total = failedTestJunitReportContent.substring(totalCounterStart,totalCounterEnd).toInteger()
|
||||
def failure = failedTestJunitReportContent.substring(failureCounterStart,failureCounterEnd).toInteger()+1
|
||||
def percent = ((1 - failure/total)*100).toInteger()
|
||||
def total = failedTestJunitReportContent.substring(totalCounterStart, totalCounterEnd).toInteger()
|
||||
def failure = failedTestJunitReportContent.substring(failureCounterStart, failureCounterEnd).toInteger() + 1
|
||||
def percent = ((1 - failure / total) * 100).toInteger()
|
||||
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.substring(0,failureCounterStart) + "$failure" + failedTestJunitReportContent.substring(failureCounterEnd)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.substring(0,percentInfoStart) + "$percent" + failedTestJunitReportContent.substring(percentInfoEnd)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.substring(0, failureCounterStart) + "$failure" + failedTestJunitReportContent.substring(failureCounterEnd)
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.substring(0, percentInfoStart) + "$percent" + failedTestJunitReportContent.substring(percentInfoEnd)
|
||||
|
||||
if (failedTestJunitReportContent.indexOf("\"infoBox success\" id=\"successRate\"") != -1) {
|
||||
failedTestJunitReportContent = failedTestJunitReportContent.replace("\"infoBox success\" id=\"successRate\"", "\"infoBox failures\" id=\"successRate\"")
|
||||
|
|
@ -387,17 +389,17 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
failedTestIndex = failedTestJunitReportContent.indexOf(failedTest)
|
||||
} else screenshotReport = "\n\n"
|
||||
|
||||
def imagesrc = "failures/${failedTestClassName}/${failedTestName}/${failedTestCase.name}"
|
||||
def imagesrc = new File("failures", failedTestClassName + File.separator + failedTestName + File.separator + failedTestCaseDescription).toString()
|
||||
|
||||
screenshotReport += "display conficts detected with \"${name}\" line ${line}: (reference | capture | difference)\n"
|
||||
screenshotReport += "<div style=\"display: table\">\n"
|
||||
screenshotReport += "<img src=\"${imagesrc}/reference.png\" width =\"220\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "<img src=\"${imagesrc}/capture.png\" width =\"220\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "<img src=\"${imagesrc}/difference.png\" width =\"220\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "<img src=\"${imagesrc + File.separator}reference.png\" width =\"230\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "<img src=\"${imagesrc + File.separator}capture.png\" width =\"230\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "<img src=\"${imagesrc + File.separator}difference.png\" width =\"230\" style=\"padding: 5px\"/>\n"
|
||||
screenshotReport += "</div>"
|
||||
|
||||
def insertIndex = failedTestJunitReportContent.indexOf("</pre>",failedTestIndex)
|
||||
def firstPart = failedTestJunitReportContent.substring(0,insertIndex)
|
||||
def insertIndex = failedTestJunitReportContent.indexOf("</pre>", failedTestIndex)
|
||||
def firstPart = failedTestJunitReportContent.substring(0, insertIndex)
|
||||
def secondPart = failedTestJunitReportContent.substring(insertIndex)
|
||||
failedTestJunitReportContent = firstPart + screenshotReport + secondPart
|
||||
|
||||
|
|
@ -405,6 +407,7 @@ def embedScreenshotsTask = task('embedScreenshots', group: 'reporting') {
|
|||
}
|
||||
}
|
||||
}
|
||||
print "see report at: ${new File(reportsDirectory, "index.html")}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ object UITestsScreenshots {
|
|||
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
|
||||
"linphone_uitests"
|
||||
).absolutePath,
|
||||
"$testClass/$testFunction/$startTime"
|
||||
testClass + File.separator + testFunction + File.separator + startTime
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ object UITestsScreenshots {
|
|||
) {
|
||||
if (!screenshotComparison) return
|
||||
if (name.contains(".") || variant?.contains(".") == true) {
|
||||
throw Exception("[UITests] \".\" character is forbidden for screencheck methods arguments name and variant")
|
||||
throw Exception("[UITests] \".\" character is forbidden for takeScreenshot methods arguments name and variant")
|
||||
}
|
||||
screenshot(line.toString() + ".$name" + if (variant != null) ".$variant" else "")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue