mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Create the fake MediaStore directory without java.nio.file
Files.createTempDirectory needs API 26 and the fake lives in the main source set of tests:testutils, so lint failed it against the minimum of 24. File.createTempFile has been available since API 1 and still gives each provider instance its own directory.
This commit is contained in:
+4
-2
@@ -17,7 +17,6 @@ import android.provider.MediaStore
|
|||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import org.robolectric.shadows.ShadowContentResolver
|
import org.robolectric.shadows.ShadowContentResolver
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stands in for the MediaStore provider: it records the display names an insert is attempted with,
|
* Stands in for the MediaStore provider: it records the display names an insert is attempted with,
|
||||||
@@ -25,7 +24,10 @@ import java.nio.file.Files
|
|||||||
* way MediaStore does once a directory already holds 32 files with the same name.
|
* way MediaStore does once a directory already holds 32 files with the same name.
|
||||||
*/
|
*/
|
||||||
class FakeMediaStoreContentProvider : ContentProvider() {
|
class FakeMediaStoreContentProvider : ContentProvider() {
|
||||||
private val directory: File = Files.createTempDirectory("fake-media-store").toFile()
|
private val directory: File = File.createTempFile("fake-media-store", null).apply {
|
||||||
|
delete()
|
||||||
|
mkdir()
|
||||||
|
}
|
||||||
|
|
||||||
val insertedDisplayNames = mutableListOf<String>()
|
val insertedDisplayNames = mutableListOf<String>()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user