Fix test compilation

This commit is contained in:
Valere 2021-04-14 18:15:50 +02:00
parent 57e9e4474e
commit 7910e84d8e
2 changed files with 24 additions and 29 deletions

View File

@ -42,7 +42,6 @@ import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.api.session.space.SpaceService import org.matrix.android.sdk.api.session.space.SpaceService
import org.matrix.android.sdk.common.CommonTestHelper import org.matrix.android.sdk.common.CommonTestHelper
import org.matrix.android.sdk.common.SessionTestParams import org.matrix.android.sdk.common.SessionTestParams
import org.matrix.android.sdk.internal.util.awaitCallback
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNotNull import kotlin.test.assertNotNull
@ -84,12 +83,12 @@ class SpaceCreationTest : InstrumentedTest {
} }
assertEquals(100, powerLevelsContent?.eventsDefault, "Space-rooms should be created with a power level for events_default of 100") assertEquals(100, powerLevelsContent?.eventsDefault, "Space-rooms should be created with a power level for events_default of 100")
val guestAccess = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_GUEST_ACCESS)?.content val guestAccess = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_GUEST_ACCESS)?.content
?.toModel<RoomGuestAccessContent>()?.guestAccess ?.toModel<RoomGuestAccessContent>()?.guestAccess
assertEquals(GuestAccess.CanJoin, guestAccess, "Public space room should be peekable by guest") assertEquals(GuestAccess.CanJoin, guestAccess, "Public space room should be peekable by guest")
val historyVisibility = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_HISTORY_VISIBILITY)?.content val historyVisibility = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_HISTORY_VISIBILITY)?.content
?.toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?.toModel<RoomHistoryVisibilityContent>()?.historyVisibility
assertEquals(RoomHistoryVisibility.WORLD_READABLE, historyVisibility, "Public space room should be world readable") assertEquals(RoomHistoryVisibility.WORLD_READABLE, historyVisibility, "Public space room should be world readable")
@ -141,13 +140,11 @@ class SpaceCreationTest : InstrumentedTest {
// create a room // create a room
val firstChild: String = runBlocking { val firstChild: String = runBlocking {
awaitCallback<String> { aliceSession.createRoom(CreateRoomParams().apply {
aliceSession.createRoom(CreateRoomParams().apply { this.name = "FirstRoom"
this.name = "FirstRoom" this.topic = "Description of first room"
this.topic = "Description of first room" this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT })
}, it)
}
} }
runBlocking { runBlocking {
@ -155,13 +152,11 @@ class SpaceCreationTest : InstrumentedTest {
} }
val secondChild: String = runBlocking { val secondChild: String = runBlocking {
awaitCallback { aliceSession.createRoom(CreateRoomParams().apply {
aliceSession.createRoom(CreateRoomParams().apply { this.name = "SecondRoom"
this.name = "SecondRoom" this.topic = "Description of second room"
this.topic = "Description of second room" this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT })
}, it)
}
} }
runBlocking { runBlocking {

View File

@ -60,8 +60,8 @@ class SpaceHierarchyTest : InstrumentedTest {
val syncedSpace = session.spaceService().getSpace(spaceId) val syncedSpace = session.spaceService().getSpace(spaceId)
val roomId = commonTestHelper.doSync<String> { val roomId = runBlocking {
session.createRoom(CreateRoomParams().apply { name = "General" }, it) session.createRoom(CreateRoomParams().apply { name = "General" })
} }
val viaServers = listOf(session.sessionParams.homeServerHost ?: "") val viaServers = listOf(session.sessionParams.homeServerHost ?: "")
@ -108,8 +108,8 @@ class SpaceHierarchyTest : InstrumentedTest {
val children = listOf("General" to true /*canonical*/, "Random" to false) val children = listOf("General" to true /*canonical*/, "Random" to false)
val roomIdList = children.map { val roomIdList = children.map {
commonTestHelper.doSync<String> { cb -> runBlocking {
session.createRoom(CreateRoomParams().apply { name = it.first }, cb) session.createRoom(CreateRoomParams().apply { name = it.first })
} to it.second } to it.second
} }
@ -169,11 +169,11 @@ class SpaceHierarchyTest : InstrumentedTest {
// Create orphan rooms // Create orphan rooms
val orphan1 = commonTestHelper.doSync<String> { cb -> val orphan1 = runBlocking {
session.createRoom(CreateRoomParams().apply { name = "O1" }, cb) session.createRoom(CreateRoomParams().apply { name = "O1" })
} }
val orphan2 = commonTestHelper.doSync<String> { cb -> val orphan2 = runBlocking {
session.createRoom(CreateRoomParams().apply { name = "O2" }, cb) session.createRoom(CreateRoomParams().apply { name = "O2" })
} }
val allRooms = session.getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) }) val allRooms = session.getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) })
@ -195,8 +195,8 @@ class SpaceHierarchyTest : InstrumentedTest {
assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A") assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A")
// Add a non canonical child and check that it does not appear as orphan // Add a non canonical child and check that it does not appear as orphan
val a3 = commonTestHelper.doSync<String> { cb -> val a3 = runBlocking {
session.createRoom(CreateRoomParams().apply { name = "A3" }, cb) session.createRoom(CreateRoomParams().apply { name = "A3" })
} }
runBlocking { runBlocking {
spaceA!!.addChildren(a3, viaServers, null, false) spaceA!!.addChildren(a3, viaServers, null, false)
@ -354,8 +354,8 @@ class SpaceHierarchyTest : InstrumentedTest {
val roomIds = val roomIds =
childInfo.map { entry -> childInfo.map { entry ->
commonTestHelper.doSync<String> { cb -> runBlocking {
session.createRoom(CreateRoomParams().apply { name = entry.first }, cb) session.createRoom(CreateRoomParams().apply { name = entry.first })
} }
} }