COntentResolverHelper: sort column must be an array

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2021-10-07 12:00:04 +02:00
parent 8860bd4b52
commit be830a66c8
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 6 additions and 2 deletions

View file

@ -28,6 +28,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import io.mockk.mockk
import io.mockk.verify
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
@ -60,7 +61,10 @@ class ContentResolverHelperTest {
withArg { bundle ->
assertEquals(bundle.getString(ContentResolver.QUERY_ARG_SQL_SELECTION), SELECTION)
assertEquals(bundle.getInt(ContentResolver.QUERY_ARG_LIMIT), LIMIT)
assertEquals(bundle.getString(ContentResolver.QUERY_ARG_SORT_COLUMNS), SORT_COLUMN)
assertArrayEquals(
bundle.getStringArray(ContentResolver.QUERY_ARG_SORT_COLUMNS),
arrayOf(SORT_COLUMN)
)
assertEquals(bundle.getInt(ContentResolver.QUERY_ARG_SORT_DIRECTION), SORT_DIRECTION_INT)
},
null

View file

@ -98,7 +98,7 @@ object ContentResolverHelper {
putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selection)
}
if (sortColumn != null) {
putString(ContentResolver.QUERY_ARG_SORT_COLUMNS, sortColumn)
putStringArray(ContentResolver.QUERY_ARG_SORT_COLUMNS, arrayOf(sortColumn))
val direction = when (sortDirection) {
SORT_DIRECTION_ASCENDING -> ContentResolver.QUERY_SORT_DIRECTION_ASCENDING
else -> ContentResolver.QUERY_SORT_DIRECTION_DESCENDING