mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Fix tests after rebase
This commit is contained in:
@@ -46,9 +46,9 @@ dependencies {
|
|||||||
implementation(projects.libraries.elementresources)
|
implementation(projects.libraries.elementresources)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
implementation(projects.features.userlist.api)
|
implementation(projects.features.userlist.api)
|
||||||
|
implementation(projects.libraries.mediapickers.api)
|
||||||
|
implementation(libs.coil.compose)
|
||||||
api(projects.features.createroom.api)
|
api(projects.features.createroom.api)
|
||||||
implementation(libs.coil.compose) // FIXME temp
|
|
||||||
implementation(projects.libraries.mediapickers)
|
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testImplementation(libs.test.junit)
|
||||||
testImplementation(libs.coroutines.test)
|
testImplementation(libs.coroutines.test)
|
||||||
@@ -59,6 +59,7 @@ dependencies {
|
|||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.features.userlist.impl)
|
testImplementation(projects.features.userlist.impl)
|
||||||
testImplementation(projects.features.userlist.test)
|
testImplementation(projects.features.userlist.test)
|
||||||
|
testImplementation(projects.libraries.mediapickers.test)
|
||||||
|
|
||||||
androidTestImplementation(libs.test.junitext)
|
androidTestImplementation(libs.test.junitext)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -35,7 +35,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
|
|||||||
import io.element.android.libraries.matrix.api.createroom.CreateRoomParameters
|
import io.element.android.libraries.matrix.api.createroom.CreateRoomParameters
|
||||||
import io.element.android.libraries.matrix.api.createroom.RoomPreset
|
import io.element.android.libraries.matrix.api.createroom.RoomPreset
|
||||||
import io.element.android.libraries.matrix.api.createroom.RoomVisibility
|
import io.element.android.libraries.matrix.api.createroom.RoomVisibility
|
||||||
import io.element.android.libraries.mediapickers.PickerProvider
|
import io.element.android.libraries.mediapickers.api.PickerProvider
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -58,7 +58,6 @@ class ConfigureRoomPresenter @Inject constructor(
|
|||||||
|
|
||||||
val cameraPhotoPicker = mediaPickerProvider.registerCameraPhotoPicker(
|
val cameraPhotoPicker = mediaPickerProvider.registerCameraPhotoPicker(
|
||||||
onResult = { uri -> if (uri != null) dataStore.setAvatarUri(uri = uri, cached = true) },
|
onResult = { uri -> if (uri != null) dataStore.setAvatarUri(uri = uri, cached = true) },
|
||||||
deleteAfter = false,
|
|
||||||
)
|
)
|
||||||
val galleryImagePicker = mediaPickerProvider.registerGalleryImagePicker(
|
val galleryImagePicker = mediaPickerProvider.registerGalleryImagePicker(
|
||||||
onResult = { uri -> if (uri != null) dataStore.setAvatarUri(uri = uri) }
|
onResult = { uri -> if (uri != null) dataStore.setAvatarUri(uri = uri) }
|
||||||
|
|||||||
+6
-3
@@ -35,7 +35,7 @@ import io.element.android.libraries.matrix.test.A_ROOM_NAME
|
|||||||
import io.element.android.libraries.matrix.test.A_THROWABLE
|
import io.element.android.libraries.matrix.test.A_THROWABLE
|
||||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||||
import io.element.android.libraries.mediapickers.PickerProvider
|
import io.element.android.libraries.mediapickers.test.FakePickerProvider
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -52,16 +52,18 @@ class ConfigureRoomPresenterTests {
|
|||||||
private lateinit var userListDataStore: UserListDataStore
|
private lateinit var userListDataStore: UserListDataStore
|
||||||
private lateinit var createRoomDataStore: CreateRoomDataStore
|
private lateinit var createRoomDataStore: CreateRoomDataStore
|
||||||
private lateinit var fakeMatrixClient: FakeMatrixClient
|
private lateinit var fakeMatrixClient: FakeMatrixClient
|
||||||
|
private lateinit var fakePickerProvider: FakePickerProvider
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
fakeMatrixClient = FakeMatrixClient()
|
fakeMatrixClient = FakeMatrixClient()
|
||||||
userListDataStore = UserListDataStore()
|
userListDataStore = UserListDataStore()
|
||||||
createRoomDataStore = CreateRoomDataStore(userListDataStore)
|
createRoomDataStore = CreateRoomDataStore(userListDataStore)
|
||||||
|
fakePickerProvider = FakePickerProvider()
|
||||||
presenter = ConfigureRoomPresenter(
|
presenter = ConfigureRoomPresenter(
|
||||||
dataStore = createRoomDataStore,
|
dataStore = createRoomDataStore,
|
||||||
matrixClient = fakeMatrixClient,
|
matrixClient = fakeMatrixClient,
|
||||||
mediaPickerProvider = PickerProvider(isInTest = true),
|
mediaPickerProvider = fakePickerProvider,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +148,8 @@ class ConfigureRoomPresenterTests {
|
|||||||
// Room avatar
|
// Room avatar
|
||||||
// Add
|
// Add
|
||||||
val anUri = Uri.parse(AN_AVATAR_URL)
|
val anUri = Uri.parse(AN_AVATAR_URL)
|
||||||
createRoomDataStore.setAvatarUri(anUri)
|
fakePickerProvider.givenResult(anUri)
|
||||||
|
newState.eventSink(ConfigureRoomEvents.HandleAvatarAction(AvatarAction.ChoosePhoto))
|
||||||
newState = awaitItem()
|
newState = awaitItem()
|
||||||
expectedConfig = expectedConfig.copy(avatarUri = anUri)
|
expectedConfig = expectedConfig.copy(avatarUri = anUri)
|
||||||
assertThat(newState.config).isEqualTo(expectedConfig)
|
assertThat(newState.config).isEqualTo(expectedConfig)
|
||||||
|
|||||||
+5
-1
@@ -27,6 +27,11 @@ interface PickerProvider {
|
|||||||
onResult: (uri: Uri?, mimeType: String?) -> Unit
|
onResult: (uri: Uri?, mimeType: String?) -> Unit
|
||||||
): PickerLauncher<PickVisualMediaRequest, Uri?>
|
): PickerLauncher<PickVisualMediaRequest, Uri?>
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun registerGalleryImagePicker(
|
||||||
|
onResult: (Uri?) -> Unit
|
||||||
|
): PickerLauncher<PickVisualMediaRequest, Uri?>
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun registerFilePicker(
|
fun registerFilePicker(
|
||||||
mimeType: String,
|
mimeType: String,
|
||||||
@@ -38,5 +43,4 @@ interface PickerProvider {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun registerCameraVideoPicker(onResult: (Uri?) -> Unit): PickerLauncher<Uri, Boolean>
|
fun registerCameraVideoPicker(onResult: (Uri?) -> Unit): PickerLauncher<Uri, Boolean>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ class PickerProviderImpl constructor(private val isInTest: Boolean) : PickerProv
|
|||||||
* [onResult] will be called with either the selected file's [Uri] or `null` if nothing was selected.
|
* [onResult] will be called with either the selected file's [Uri] or `null` if nothing was selected.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun registerGalleryImagePicker(onResult: (Uri?) -> Unit): PickerLauncher<PickVisualMediaRequest, Uri?> {
|
override fun registerGalleryImagePicker(onResult: (Uri?) -> Unit): PickerLauncher<PickVisualMediaRequest, Uri?> {
|
||||||
// Tests and UI preview can't handle Contexts, so we might as well disable the whole picker
|
// Tests and UI preview can't handle Contexts, so we might as well disable the whole picker
|
||||||
return if (LocalInspectionMode.current || isInTest) {
|
return if (LocalInspectionMode.current || isInTest) {
|
||||||
NoOpPickerLauncher { onResult(null) }
|
NoOpPickerLauncher { onResult(null) }
|
||||||
|
|||||||
+5
@@ -33,6 +33,11 @@ class FakePickerProvider : PickerProvider {
|
|||||||
return NoOpPickerLauncher { onResult(result, mimeType) }
|
return NoOpPickerLauncher { onResult(result, mimeType) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
override fun registerGalleryImagePicker(onResult: (uri: Uri?) -> Unit): PickerLauncher<PickVisualMediaRequest, Uri?> {
|
||||||
|
return NoOpPickerLauncher { onResult(result) }
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun registerFilePicker(mimeType: String, onResult: (Uri?) -> Unit): PickerLauncher<String, Uri?> {
|
override fun registerFilePicker(mimeType: String, onResult: (Uri?) -> Unit): PickerLauncher<String, Uri?> {
|
||||||
return NoOpPickerLauncher { onResult(result) }
|
return NoOpPickerLauncher { onResult(result) }
|
||||||
|
|||||||
Reference in New Issue
Block a user