Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOException in BasicScreenCaptureProcessor.process #818

Open
yogurtearl opened this issue Nov 27, 2020 · 1 comment
Open

IOException in BasicScreenCaptureProcessor.process #818

yogurtearl opened this issue Nov 27, 2020 · 1 comment

Comments

@yogurtearl
Copy link
Contributor

yogurtearl commented Nov 27, 2020

Description

BasicScreenCaptureProcessor uses a deprecated method (Environment#getExternalStoragePublicDirectory) for storing screenshot files.

I know that BasicScreenCaptureProcessor might be deprecated someday... (see #383), but would be nice if it worked in the mean time.

public BasicScreenCaptureProcessor() {
this(new File(getExternalStoragePublicDirectory(DIRECTORY_PICTURES), "screenshots"));
}

Can use the logic from Facebook screenshotter, which seems to work accross API 23-30 on FTL

essentially, Facebook screenshotter does the below, plus they call dir.setWritable(/* writeable = */ true, /* ownerOnly = */ false); and they grant permissions if needed.

  public BasicScreenCaptureProcessor() {
    this(new File(System.getenv("EXTERNAL_STORAGE"), "screenshots"));
  }

Any solution should be compatible with the FTL directories-to-pull option

These must be absolute paths under /sdcard, /storage, or /data/local/tmp

Steps to Reproduce

run Screenshot.capture().process() in a test on API 23 virtual device on FTL

Expected Results

Saves screenshot to disk.

Actual Results

Exception.

E/TestRunner(6545): Caused by: java.io.IOException: The directory /storage/emulated/0/Pictures/screenshots does not exist and could not be created or is not writable.
E/TestRunner(6545): 	at androidx.test.runner.screenshot.BasicScreenCaptureProcessor.process(BasicScreenCaptureProcessor.java:72)
E/TestRunner(6545): 	at androidx.test.runner.screenshot.ScreenCapture.process(ScreenCapture.java:140)
E/TestRunner(6545): 	at androidx.test.runner.screenshot.ScreenCapture.process(ScreenCapture.java:126)
E/TestRunner(6545): 	... 34 more

AndroidX Test and Android OS Versions

AndroidX test 1.3.0, API 23

@sushantchoudhary
Copy link

sushantchoudhary commented Mar 12, 2021

@brettchabot , @slinzner Any update on this issue? or any other workaround to run tests on FTL with API 30?

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

No branches or pull requests

2 participants