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

#270. temp solutions for Storage issues #309

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,52 @@ cd ~/Workspace/Kaspresso
java -jar artifacts/adbserver-desktop.jar
```

## Storage issues
Kaspresso can use external storage to save various data about executed tests. The example of such data is screenshots, xml dumps, logs, video and anymore.
But, new Android OS provides absolutely new way to work with external storage - Scoped Storage. Currently, we are working on the support of Scoped Storage.
While Scoped Storage support is on the way, there is an option to request different permissions to make an access to saved data possible on any Android OS.
Here, it's a detailed instruction:
1. AndroidManifest.xml (in your debug build variant to keep production manifest without any changes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test app manifest

```xml
# Please, add these permissions
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

<application
# storage support for Android API 29
android:requestLegacyExternalStorage="true"
...
</application>
```
2. Your test class:
```kotlin
class SampleTest : TestCase(
kaspressoBuilder = Kaspresso.Builder.simple( // simple/advanced - it doesn't matter
customize = {
// storage support for Android API 30+
if (isAndroidRuntime) {
UiDevice
.getInstance(instrumentation)
.executeShellCommand("appops set --uid ${InstrumentationRegistry.getInstrumentation().targetContext.packageName} MANAGE_EXTERNAL_STORAGE allow")
}
}
)
) {

// storage support for Android API 29-
@get:Rule
val runtimePermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
matzuk marked this conversation as resolved.
Show resolved Hide resolved
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)

//...
}
```
Remember, it's a temporary working solution.
A little bit later, Kaspresso will use external storage only through Scoped Storage and you will not be forced to request all mentioned permissions.

## Breaking changes
### 1.2.0
- We've totally reworked AdbServer and Kaspresso 1.2.0 works only with new `artifacts/adbserver-desktop.jar`<br>
Expand Down