Skip to content

Commit

Permalink
♻️ Tweak screenshot taking script
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Colman Lopes <[email protected]>
  • Loading branch information
LeoColman committed Jan 25, 2025
1 parent 1eb7b5c commit 19cad57
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions app/refresh_screenshots.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fun disableAnimations() {
listOf(
"adb shell settings put global window_animation_scale 0",
"adb shell settings put global transition_animation_scale 0",
"adb shell settings put global animator_duration_scale 0",
"adb shell settings put global animator_duration_scale 0"
).forEach { command ->
try {
val process = Runtime.getRuntime().exec(command)
Expand All @@ -33,19 +33,16 @@ fun disableAnimations() {
println("Error while trying to disable animations via ADB: ${e.localizedMessage}")
}
}
println("Animations in the emulator has been disabled")
println("Animations in the emulator have been disabled")
}

// Function to start the server
fun startServer(): NettyApplicationEngine {
return embeddedServer(Netty, port = 8081) {
install(ContentNegotiation) {
json()
}
routing {
post("/upload") {
println("Received upload")
println(call.parameters)
val multipart = call.receiveMultipart()
val lang = call.parameters["lang"] ?: "unknown"
val country = call.parameters["country"] ?: "unknown"
Expand All @@ -68,28 +65,20 @@ fun startServer(): NettyApplicationEngine {
}.start(wait = false)
}


// Start the server
val server = startServer()

// Disable Animations
// Disable animations
disableAnimations()

// Run the Android tests
println("Running Android tests...")
// Run Android tests
val process = ProcessBuilder(
"../gradlew",
"connectedFdroidDebugAndroidTest",
"-Pandroid.testInstrumentationRunnerArguments.class=br.com.colman.petals.ScreenshotTakerTest"
).inheritIO().start()
val exitCode = process.waitFor()

if (exitCode == 0) {
println("Tests ran successfully")
} else {
println("Tests failed with exit code $exitCode")
}

// Stop the server
println("Stopping server...")
server.stop(1000, 10000)
println("Server stopped")

0 comments on commit 19cad57

Please sign in to comment.