Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Old Screenshots piling up #150

Open
Ankhwatcher opened this issue Jun 14, 2018 · 3 comments
Open

Old Screenshots piling up #150

Ankhwatcher opened this issue Jun 14, 2018 · 3 comments
Assignees

Comments

@Ankhwatcher
Copy link

Hey folks,

I'm using Composer with Spoon 2.0 for screenshots.
(If there is a native way to take screenshots in Composer or a better recommended tool please let me know!)

My screenshots are being taken and downloaded and added to the report okay, but all previous screenshots from all previous runs are also in the report.

It doesn't matter if I run composer as a clean or not.

Any help or guidance here would be greatly appreciated.

Thanks,
ANkh

@tokou
Copy link

tokou commented Jun 14, 2018

I have a run listener that cleans them before each run.
You can add it by passing the listener instrumentation argument.

Example : --instrumentation-arguments listener my.package.ClearSpoonScreenshotsRunListener

import android.os.Environment
import android.support.test.internal.runner.listener.InstrumentationRunListener
import android.support.test.runner.permission.PermissionRequester
import android.util.Log
import org.junit.runner.Description

class ClearSpoonScreenshotsRunListener : InstrumentationRunListener() {

    override fun testRunStarted(description: Description?) {
        super.testRunStarted(description)
        clearSpoonScreenshots()
    }

    private val TAG = "ClearSpoonScreenshotsRunListener"

    fun clearSpoonScreenshots() {
        val requester = PermissionRequester()
        requester.addPermissions(
            android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
            android.Manifest.permission.READ_EXTERNAL_STORAGE)
        requester.requestPermissions()
        val root = Environment.getExternalStoragePublicDirectory("app_spoon-screenshots")
        val deleteRecursively = root.deleteRecursively()
        val result = if (deleteRecursively) "success" else "failure"
        Log.i(TAG, "clearing screenshots from folder ${root.absolutePath} $result")
    }

}

@Sloy
Copy link

Sloy commented Jun 15, 2018

We're doing a similar thing from Gradle after the testComposerDebug task (we're using the third party Gradle plugin).

I also think this should be done by Composer after successfully pulling the files. Maybe having some option to skip it, since it's helpful keeping the files for debugging purposes.

@yunikkk yunikkk self-assigned this Jun 15, 2018
@trevjonez
Copy link

trevjonez commented Jun 15, 2018

its should be pretty easy to follow with an adb command to delete the file after they pull it.
i do exactly that when pulling bitmaps in kontrast.
https://github.com/trevjonez/Kontrast/blob/master/plugin/src/main/kotlin/com/trevjonez/kontrast/task/RenderOnDeviceTask.kt#L139

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants