mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 02:45:53 +03:00
Merge pull request #3270 from vector-im/feature/bma/remove_jcenter
https://github.com/Piasy/BigImageViewer is now hosted on mavenCentral()
This commit is contained in:
commit
dd325c4e91
8 changed files with 56 additions and 61 deletions
|
@ -27,6 +27,7 @@ SDK API changes ⚠️:
|
||||||
|
|
||||||
Build 🧱:
|
Build 🧱:
|
||||||
- Upgrade to gradle 7
|
- Upgrade to gradle 7
|
||||||
|
- https://github.com/Piasy/BigImageViewer is now hosted on mavenCentral()
|
||||||
|
|
||||||
Test:
|
Test:
|
||||||
-
|
-
|
||||||
|
|
|
@ -50,12 +50,6 @@ allprojects {
|
||||||
includeGroupByRegex 'nl\\.dionsegijn'
|
includeGroupByRegex 'nl\\.dionsegijn'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
url "https://dl.bintray.com/piasy/maven"
|
|
||||||
content {
|
|
||||||
includeGroupByRegex "com\\.github\\.piasy"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||||
// Jitsi repo
|
// Jitsi repo
|
||||||
maven {
|
maven {
|
||||||
|
@ -64,6 +58,7 @@ allprojects {
|
||||||
// url "file:///Users/bmarty/workspaces/jitsi_libre_maven/android-sdk-3.1.0"
|
// url "file:///Users/bmarty/workspaces/jitsi_libre_maven/android-sdk-3.1.0"
|
||||||
}
|
}
|
||||||
google()
|
google()
|
||||||
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ dependencies {
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||||
androidTestImplementation 'org.amshove.kluent:kluent-android:1.61'
|
androidTestImplementation 'org.amshove.kluent:kluent-android:1.65'
|
||||||
androidTestImplementation 'io.mockk:mockk-android:1.11.0'
|
androidTestImplementation 'io.mockk:mockk-android:1.11.0'
|
||||||
androidTestImplementation "androidx.arch.core:core-testing:$arch_version"
|
androidTestImplementation "androidx.arch.core:core-testing:$arch_version"
|
||||||
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.crypto
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -29,8 +31,6 @@ import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyContent
|
import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyContent
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertNotNull
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -54,7 +54,7 @@ class PreShareKeysTest : InstrumentedTest {
|
||||||
&& it.getClearType() == EventType.ROOM_KEY
|
&& it.getClearType() == EventType.ROOM_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(0, preShareCount, "Bob should not have receive any key from alice at this point")
|
assertEquals("Bob should not have receive any key from alice at this point", 0, preShareCount)
|
||||||
Log.d("#Test", "Room Key Received from alice $preShareCount")
|
Log.d("#Test", "Room Key Received from alice $preShareCount")
|
||||||
|
|
||||||
// Force presharing of new outbound key
|
// Force presharing of new outbound key
|
||||||
|
@ -78,14 +78,14 @@ class PreShareKeysTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
val content = latest?.getClearContent().toModel<RoomKeyContent>()
|
val content = latest?.getClearContent().toModel<RoomKeyContent>()
|
||||||
assertNotNull(content, "Bob should have received and decrypted a room key event from alice")
|
assertNotNull("Bob should have received and decrypted a room key event from alice", content)
|
||||||
assertEquals(e2eRoomID, content.roomId, "Wrong room")
|
assertEquals("Wrong room", e2eRoomID, content!!.roomId)
|
||||||
val megolmSessionId = content.sessionId!!
|
val megolmSessionId = content.sessionId!!
|
||||||
|
|
||||||
val sharedIndex = aliceSession.cryptoService().getSharedWithInfo(e2eRoomID, megolmSessionId)
|
val sharedIndex = aliceSession.cryptoService().getSharedWithInfo(e2eRoomID, megolmSessionId)
|
||||||
.getObject(bobSession.myUserId, bobSession.sessionParams.deviceId)
|
.getObject(bobSession.myUserId, bobSession.sessionParams.deviceId)
|
||||||
|
|
||||||
assertEquals(0, sharedIndex, "The session received by bob should match what alice sent")
|
assertEquals("The session received by bob should match what alice sent", 0, sharedIndex)
|
||||||
|
|
||||||
// Just send a real message as test
|
// Just send a real message as test
|
||||||
val sentEvent = mTestHelper.sendTextMessage(aliceSession.getRoom(e2eRoomID)!!, "Allo", 1).first()
|
val sentEvent = mTestHelper.sendTextMessage(aliceSession.getRoom(e2eRoomID)!!, "Allo", 1).first()
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.session.room.timeline
|
package org.matrix.android.sdk.session.room.timeline
|
||||||
|
|
||||||
|
import org.junit.Assert.fail
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -29,7 +30,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import kotlin.test.fail
|
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -80,6 +80,7 @@ class TimelineWithManyMembersTest : InstrumentedTest {
|
||||||
return@createEventListener true
|
return@createEventListener true
|
||||||
} else {
|
} else {
|
||||||
fail("User " + session.myUserId + " decrypted as " + body + " CryptoError: " + it.root.mCryptoError)
|
fail("User " + session.myUserId + " decrypted as " + body + " CryptoError: " + it.root.mCryptoError)
|
||||||
|
false
|
||||||
}
|
}
|
||||||
} ?: return@createEventListener false
|
} ?: return@createEventListener false
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.session.space
|
||||||
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -42,8 +44,6 @@ import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
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 kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertNotNull
|
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -68,8 +68,8 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
assertEquals(topic, syncedSpace?.asRoom()?.roomSummary()?.topic, "Room topic should be set")
|
assertEquals(topic, syncedSpace?.asRoom()?.roomSummary()?.topic, "Room topic should be set")
|
||||||
// assertEquals(topic, syncedSpace.asRoom().roomSummary()?., "Room topic should be set")
|
// assertEquals(topic, syncedSpace.asRoom().roomSummary()?., "Room topic should be set")
|
||||||
|
|
||||||
assertNotNull(syncedSpace, "Space should be found by Id")
|
assertNotNull("Space should be found by Id", syncedSpace)
|
||||||
val creationEvent = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_CREATE)
|
val creationEvent = syncedSpace!!.asRoom().getStateEvent(EventType.STATE_ROOM_CREATE)
|
||||||
val createContent = creationEvent?.content.toModel<RoomCreateContent>()
|
val createContent = creationEvent?.content.toModel<RoomCreateContent>()
|
||||||
assertEquals(RoomType.SPACE, createContent?.type, "Room type should be space")
|
assertEquals(RoomType.SPACE, createContent?.type, "Room type should be space")
|
||||||
|
|
||||||
|
@ -81,17 +81,17 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
toModel != null
|
toModel != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(100, powerLevelsContent?.eventsDefault, "Space-rooms should be created with a power level for events_default of 100")
|
assertEquals("Space-rooms should be created with a power level for events_default of 100", 100, powerLevelsContent?.eventsDefault)
|
||||||
|
|
||||||
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("Public space room should be peekable by guest", GuestAccess.CanJoin, guestAccess)
|
||||||
|
|
||||||
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("Public space room should be world readable", RoomHistoryVisibility.WORLD_READABLE, historyVisibility)
|
||||||
|
|
||||||
commonTestHelper.signOutAndClose(session)
|
commonTestHelper.signOutAndClose(session)
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
// check if bob has joined automatically the first room
|
// check if bob has joined automatically the first room
|
||||||
|
|
||||||
val bobMembershipFirstRoom = bobSession.getRoom(firstChild)?.roomSummary()?.membership
|
val bobMembershipFirstRoom = bobSession.getRoom(firstChild)?.roomSummary()?.membership
|
||||||
assertEquals(Membership.JOIN, bobMembershipFirstRoom, "Bob should have joined this room")
|
assertEquals("Bob should have joined this room", Membership.JOIN, bobMembershipFirstRoom)
|
||||||
RoomSummaryQueryParams.Builder()
|
RoomSummaryQueryParams.Builder()
|
||||||
|
|
||||||
val spaceSummaryBobPov = bobSession.spaceService().getSpaceSummaries(roomSummaryQueryParams {
|
val spaceSummaryBobPov = bobSession.spaceService().getSpaceSummaries(roomSummaryQueryParams {
|
||||||
|
@ -186,7 +186,7 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
}).firstOrNull()
|
}).firstOrNull()
|
||||||
|
|
||||||
assertEquals(2, spaceSummaryBobPov?.spaceChildren?.size ?: -1, "Unexpected number of children")
|
assertEquals("Unexpected number of children", 2, spaceSummaryBobPov?.spaceChildren?.size ?: -1)
|
||||||
|
|
||||||
commonTestHelper.signOutAndClose(aliceSession)
|
commonTestHelper.signOutAndClose(aliceSession)
|
||||||
commonTestHelper.signOutAndClose(bobSession)
|
commonTestHelper.signOutAndClose(bobSession)
|
||||||
|
|
|
@ -23,6 +23,9 @@ import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -36,9 +39,6 @@ import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
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 kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertNotNull
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -84,11 +84,11 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull(parents)
|
assertNotNull(parents)
|
||||||
assertEquals(1, parents.size)
|
assertEquals(1, parents!!.size)
|
||||||
assertEquals(spaceName, parents.first().roomSummary?.name)
|
assertEquals(spaceName, parents.first().roomSummary?.name)
|
||||||
|
|
||||||
assertNotNull(canonicalParents)
|
assertNotNull(canonicalParents)
|
||||||
assertEquals(1, canonicalParents.size)
|
assertEquals(1, canonicalParents!!.size)
|
||||||
assertEquals(spaceName, canonicalParents.first().roomSummary?.name)
|
assertEquals(spaceName, canonicalParents.first().roomSummary?.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +133,9 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
val canonicalParents = session.getRoom(it.first)?.roomSummary()?.spaceParents?.filter { it.canonical == true }
|
val canonicalParents = session.getRoom(it.first)?.roomSummary()?.spaceParents?.filter { it.canonical == true }
|
||||||
|
|
||||||
assertNotNull(parents)
|
assertNotNull(parents)
|
||||||
assertEquals(1, parents.size, "Unexpected number of parent")
|
assertEquals("Unexpected number of parent", 1, parents!!.size)
|
||||||
assertEquals(spaceName, parents.first().roomSummary?.name, "Unexpected parent name ")
|
assertEquals("Unexpected parent name", spaceName, parents.first().roomSummary?.name)
|
||||||
assertEquals(if (it.second) 1 else 0, canonicalParents?.size ?: 0, "Parent of ${it.first} should be canonical ${it.second}")
|
assertEquals("Parent of ${it.first} should be canonical ${it.second}", if (it.second) 1 else 0, canonicalParents?.size ?: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,21 +178,21 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
|
|
||||||
val allRooms = session.getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) })
|
val allRooms = session.getRoomSummaries(roomSummaryQueryParams { excludeType = listOf(RoomType.SPACE) })
|
||||||
|
|
||||||
assertEquals(9, allRooms.size, "Unexpected number of rooms")
|
assertEquals("Unexpected number of rooms", 9, allRooms.size)
|
||||||
|
|
||||||
val orphans = session.getFlattenRoomSummaryChildrenOf(null)
|
val orphans = session.getFlattenRoomSummaryChildrenOf(null)
|
||||||
|
|
||||||
assertEquals(2, orphans.size, "Unexpected number of orphan rooms")
|
assertEquals("Unexpected number of orphan rooms", 2, orphans.size)
|
||||||
assertTrue(orphans.indexOfFirst { it.roomId == orphan1 } != -1, "O1 should be an orphan")
|
assertTrue("O1 should be an orphan", orphans.any { it.roomId == orphan1 })
|
||||||
assertTrue(orphans.indexOfFirst { it.roomId == orphan2 } != -1, "O2 should be an orphan ${orphans.map { it.name }}")
|
assertTrue("O2 should be an orphan ${orphans.map { it.name }}", orphans.any { it.roomId == orphan2 })
|
||||||
|
|
||||||
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
||||||
|
|
||||||
assertEquals(4, aChildren.size, "Unexpected number of flatten child rooms")
|
assertEquals("Unexpected number of flatten child rooms", 4, aChildren.size)
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "A1" } != -1, "A1 should be a child of A")
|
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "A2" } != -1, "A2 should be a child of A")
|
assertTrue("A2 should be a child of A", aChildren.any { it.name == "A2" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "C1" } != -1, "CA should be a grand child of A")
|
assertTrue("CA should be a grand child of A", aChildren.any { it.name == "C1" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A")
|
assertTrue("A1 should be a grand child of A", aChildren.any { it.name == "C2" })
|
||||||
|
|
||||||
// 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 = runBlocking {
|
val a3 = runBlocking {
|
||||||
|
@ -205,7 +205,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
val orphansUpdate = session.getFlattenRoomSummaryChildrenOf(null)
|
val orphansUpdate = session.getFlattenRoomSummaryChildrenOf(null)
|
||||||
assertEquals(2, orphansUpdate.size, "Unexpected number of orphan rooms ${orphansUpdate.map { it.name }}")
|
assertEquals("Unexpected number of orphan rooms ${orphansUpdate.map { it.name }}", 2, orphansUpdate.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -242,11 +242,11 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
|
|
||||||
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId)
|
||||||
|
|
||||||
assertEquals(4, aChildren.size, "Unexpected number of flatten child rooms ${aChildren.map { it.name }}")
|
assertEquals("Unexpected number of flatten child rooms ${aChildren.map { it.name }}", 4, aChildren.size)
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "A1" } != -1, "A1 should be a child of A")
|
assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "A2" } != -1, "A2 should be a child of A")
|
assertTrue("A2 should be a child of A", aChildren.any { it.name == "A2" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "C1" } != -1, "CA should be a grand child of A")
|
assertTrue("CA should be a grand child of A", aChildren.any { it.name == "C1" })
|
||||||
assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A")
|
assertTrue("A1 should be a grand child of A", aChildren.any { it.name == "C2" })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -282,9 +282,7 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
override fun onChanged(children: List<RoomSummary>?) {
|
override fun onChanged(children: List<RoomSummary>?) {
|
||||||
// Log.d("## TEST", "Space A flat children update : ${children?.map { it.name }}")
|
// Log.d("## TEST", "Space A flat children update : ${children?.map { it.name }}")
|
||||||
System.out.println("## TEST | Space A flat children update : ${children?.map { it.name }}")
|
System.out.println("## TEST | Space A flat children update : ${children?.map { it.name }}")
|
||||||
if (children?.indexOfFirst { it.name == "C1" } != -1
|
if (children?.any { it.name == "C1" } == true && children.any { it.name == "C2" }) {
|
||||||
&& children?.indexOfFirst { it.name == "C2" } != -1
|
|
||||||
) {
|
|
||||||
// B1 has been added live!
|
// B1 has been added live!
|
||||||
latch.countDown()
|
latch.countDown()
|
||||||
flatAChildren.removeObserver(this)
|
flatAChildren.removeObserver(this)
|
||||||
|
@ -409,6 +407,6 @@ class SpaceHierarchyTest : InstrumentedTest {
|
||||||
|
|
||||||
val rootSpaces = session.spaceService().getRootSpaceSummaries()
|
val rootSpaces = session.spaceService().getRootSpaceSummaries()
|
||||||
|
|
||||||
assertEquals(2, rootSpaces.size, "Unexpected number of root spaces ${rootSpaces.map { it.name }}")
|
assertEquals("Unexpected number of root spaces ${rootSpaces.map { it.name }}", 2, rootSpaces.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.util
|
package org.matrix.android.sdk.internal.util
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.MatrixTest
|
import org.matrix.android.sdk.MatrixTest
|
||||||
import org.matrix.android.sdk.internal.session.room.summary.Graph
|
import org.matrix.android.sdk.internal.session.room.summary.Graph
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertNotNull
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
class GraphUtilsTest : MatrixTest {
|
class GraphUtilsTest : MatrixTest {
|
||||||
|
@ -44,7 +44,7 @@ class GraphUtilsTest : MatrixTest {
|
||||||
|
|
||||||
val backEdges = graph.findBackwardEdges(graph.getOrCreateNode("E"))
|
val backEdges = graph.findBackwardEdges(graph.getOrCreateNode("E"))
|
||||||
|
|
||||||
assertTrue(backEdges.isEmpty(), "There should not be any cycle in this graphs")
|
assertTrue("There should not be any cycle in this graphs", backEdges.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -68,21 +68,21 @@ class GraphUtilsTest : MatrixTest {
|
||||||
val backEdges = graph.findBackwardEdges(graph.getOrCreateNode("E"))
|
val backEdges = graph.findBackwardEdges(graph.getOrCreateNode("E"))
|
||||||
System.out.println(backEdges.joinToString(" | ") { "${it.source.name} -> ${it.destination.name}" })
|
System.out.println(backEdges.joinToString(" | ") { "${it.source.name} -> ${it.destination.name}" })
|
||||||
|
|
||||||
assertTrue(backEdges.size == 2, "There should be 2 backward edges not ${backEdges.size}")
|
assertEquals("There should be 2 backward edges not ${backEdges.size}", 2, backEdges.size)
|
||||||
|
|
||||||
val edge1 = backEdges.find { it.source.name == "C" }
|
val edge1 = backEdges.find { it.source.name == "C" }
|
||||||
assertNotNull(edge1, "There should be a back edge from C")
|
assertNotNull("There should be a back edge from C", edge1)
|
||||||
assertEquals("E", edge1.destination.name, "There should be a back edge C -> E")
|
assertEquals("There should be a back edge C -> E", "E", edge1!!.destination.name)
|
||||||
|
|
||||||
val edge2 = backEdges.find { it.source.name == "B" }
|
val edge2 = backEdges.find { it.source.name == "B" }
|
||||||
assertNotNull(edge2, "There should be a back edge from B")
|
assertNotNull("There should be a back edge from B", edge2)
|
||||||
assertEquals("B", edge2.destination.name, "There should be a back edge C -> C")
|
assertEquals("There should be a back edge C -> C", "B", edge2!!.destination.name)
|
||||||
|
|
||||||
// clean the graph
|
// clean the graph
|
||||||
val acyclicGraph = graph.withoutEdges(backEdges)
|
val acyclicGraph = graph.withoutEdges(backEdges)
|
||||||
System.out.println(acyclicGraph.toString())
|
System.out.println(acyclicGraph.toString())
|
||||||
|
|
||||||
assertTrue(acyclicGraph.findBackwardEdges(acyclicGraph.getOrCreateNode("E")).isEmpty(), "There should be no backward edges")
|
assertTrue("There should be no backward edges", acyclicGraph.findBackwardEdges(acyclicGraph.getOrCreateNode("E")).isEmpty())
|
||||||
|
|
||||||
val flatten = acyclicGraph.flattenDestination()
|
val flatten = acyclicGraph.flattenDestination()
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class GraphUtilsTest : MatrixTest {
|
||||||
assertTrue(flattenParentsB.contains(acyclicGraph.getOrCreateNode("A")))
|
assertTrue(flattenParentsB.contains(acyclicGraph.getOrCreateNode("A")))
|
||||||
|
|
||||||
val flattenParentsE = flatten[acyclicGraph.getOrCreateNode("E")]
|
val flattenParentsE = flatten[acyclicGraph.getOrCreateNode("E")]
|
||||||
assertTrue(flattenParentsE!!.size == 3)
|
assertEquals(3, flattenParentsE!!.size)
|
||||||
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("A")))
|
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("A")))
|
||||||
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("C")))
|
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("C")))
|
||||||
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("D")))
|
assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("D")))
|
||||||
|
|
Loading…
Reference in a new issue