From 0a9fdea26de5dff22876b653b89bae32e66bad34 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 May 2021 00:27:28 +0200 Subject: [PATCH 1/4] https://github.com/Piasy/BigImageViewer is now hosted on mavenCentral() --- CHANGES.md | 1 + build.gradle | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 74b008bfc4..7fd985c849 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ SDK API changes ⚠️: Build 🧱: - Upgrade to gradle 7 + - https://github.com/Piasy/BigImageViewer is now hosted on mavenCentral() Test: - diff --git a/build.gradle b/build.gradle index 25734e3b09..faf0fcf0b9 100644 --- a/build.gradle +++ b/build.gradle @@ -50,12 +50,6 @@ allprojects { 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/' } // Jitsi repo maven { @@ -64,6 +58,7 @@ allprojects { // url "file:///Users/bmarty/workspaces/jitsi_libre_maven/android-sdk-3.1.0" } google() + mavenCentral() jcenter() } From 4189db0f89aacf47b66bd4bb6f69c8de0e295f98 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 4 May 2021 10:50:31 +0200 Subject: [PATCH 2/4] Use Junit import --- .../sdk/internal/util/GraphUtilsTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/util/GraphUtilsTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/util/GraphUtilsTest.kt index 618f6f4714..d28192a282 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/util/GraphUtilsTest.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/util/GraphUtilsTest.kt @@ -16,14 +16,14 @@ 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.Test import org.junit.runners.MethodSorters import org.matrix.android.sdk.MatrixTest 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) class GraphUtilsTest : MatrixTest { @@ -44,7 +44,7 @@ class GraphUtilsTest : MatrixTest { 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 @@ -68,21 +68,21 @@ class GraphUtilsTest : MatrixTest { val backEdges = graph.findBackwardEdges(graph.getOrCreateNode("E")) 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" } - assertNotNull(edge1, "There should be a back edge from C") - assertEquals("E", edge1.destination.name, "There should be a back edge C -> E") + assertNotNull("There should be a back edge from C", edge1) + assertEquals("There should be a back edge C -> E", "E", edge1!!.destination.name) val edge2 = backEdges.find { it.source.name == "B" } - assertNotNull(edge2, "There should be a back edge from B") - assertEquals("B", edge2.destination.name, "There should be a back edge C -> C") + assertNotNull("There should be a back edge from B", edge2) + assertEquals("There should be a back edge C -> C", "B", edge2!!.destination.name) // clean the graph val acyclicGraph = graph.withoutEdges(backEdges) 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() @@ -93,7 +93,7 @@ class GraphUtilsTest : MatrixTest { assertTrue(flattenParentsB.contains(acyclicGraph.getOrCreateNode("A"))) 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("C"))) assertTrue(flattenParentsE.contains(acyclicGraph.getOrCreateNode("D"))) From ee7518bf5149e8aebb97309092c3ec58c0044f0c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 4 May 2021 10:51:07 +0200 Subject: [PATCH 3/4] Dependabot missed this one (?) --- matrix-sdk-android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index ea94d44346..a6e730e795 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -187,7 +187,7 @@ dependencies { androidTestImplementation 'androidx.test:rules:1.3.0' androidTestImplementation 'androidx.test.ext:junit:1.1.2' 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 "androidx.arch.core:core-testing:$arch_version" androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version" From 61380bf48a31a62379e1599a5ba985906b4115fe Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 4 May 2021 15:28:52 +0200 Subject: [PATCH 4/4] Use Junit import --- .../sdk/internal/crypto/PreShareKeysTest.kt | 12 ++--- .../timeline/TimelineWithManyMembersTest.kt | 3 +- .../sdk/session/space/SpaceCreationTest.kt | 18 +++---- .../sdk/session/space/SpaceHierarchyTest.kt | 52 +++++++++---------- 4 files changed, 42 insertions(+), 43 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt index 122584142e..a2566c1414 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt @@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.crypto import android.util.Log import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull import org.junit.FixMethodOrder import org.junit.Test 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.internal.crypto.model.event.EncryptedEventContent import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyContent -import kotlin.test.assertEquals -import kotlin.test.assertNotNull @RunWith(AndroidJUnit4::class) @FixMethodOrder(MethodSorters.JVM) @@ -54,7 +54,7 @@ class PreShareKeysTest : InstrumentedTest { && 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") // Force presharing of new outbound key @@ -78,14 +78,14 @@ class PreShareKeysTest : InstrumentedTest { } val content = latest?.getClearContent().toModel() - assertNotNull(content, "Bob should have received and decrypted a room key event from alice") - assertEquals(e2eRoomID, content.roomId, "Wrong room") + assertNotNull("Bob should have received and decrypted a room key event from alice", content) + assertEquals("Wrong room", e2eRoomID, content!!.roomId) val megolmSessionId = content.sessionId!! val sharedIndex = aliceSession.cryptoService().getSharedWithInfo(e2eRoomID, megolmSessionId) .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 val sentEvent = mTestHelper.sendTextMessage(aliceSession.getRoom(e2eRoomID)!!, "Allo", 1).first() diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineWithManyMembersTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineWithManyMembersTest.kt index ff07cf1d1d..ace48cef77 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineWithManyMembersTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineWithManyMembersTest.kt @@ -16,6 +16,7 @@ package org.matrix.android.sdk.session.room.timeline +import org.junit.Assert.fail import org.junit.FixMethodOrder import org.junit.Test 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.CryptoTestHelper import java.util.concurrent.CountDownLatch -import kotlin.test.fail @RunWith(JUnit4::class) @FixMethodOrder(MethodSorters.JVM) @@ -80,6 +80,7 @@ class TimelineWithManyMembersTest : InstrumentedTest { return@createEventListener true } else { fail("User " + session.myUserId + " decrypted as " + body + " CryptoError: " + it.root.mCryptoError) + false } } ?: return@createEventListener false } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceCreationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceCreationTest.kt index 278762671b..3fec1145d1 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceCreationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceCreationTest.kt @@ -18,6 +18,8 @@ package org.matrix.android.sdk.session.space import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull import org.junit.FixMethodOrder import org.junit.Test 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.common.CommonTestHelper import org.matrix.android.sdk.common.SessionTestParams -import kotlin.test.assertEquals -import kotlin.test.assertNotNull @RunWith(JUnit4::class) @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()?., "Room topic should be set") - assertNotNull(syncedSpace, "Space should be found by Id") - val creationEvent = syncedSpace.asRoom().getStateEvent(EventType.STATE_ROOM_CREATE) + assertNotNull("Space should be found by Id", syncedSpace) + val creationEvent = syncedSpace!!.asRoom().getStateEvent(EventType.STATE_ROOM_CREATE) val createContent = creationEvent?.content.toModel() assertEquals(RoomType.SPACE, createContent?.type, "Room type should be space") @@ -81,17 +81,17 @@ class SpaceCreationTest : InstrumentedTest { 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 ?.toModel()?.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 ?.toModel()?.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) } @@ -178,7 +178,7 @@ class SpaceCreationTest : InstrumentedTest { // check if bob has joined automatically the first room 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() val spaceSummaryBobPov = bobSession.spaceService().getSpaceSummaries(roomSummaryQueryParams { @@ -186,7 +186,7 @@ class SpaceCreationTest : InstrumentedTest { this.memberships = listOf(Membership.JOIN) }).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(bobSession) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt index 2fed7e338e..383108e633 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt @@ -23,6 +23,9 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch 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.Test 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.common.CommonTestHelper import org.matrix.android.sdk.common.SessionTestParams -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertTrue @RunWith(JUnit4::class) @FixMethodOrder(MethodSorters.JVM) @@ -84,11 +84,11 @@ class SpaceHierarchyTest : InstrumentedTest { } assertNotNull(parents) - assertEquals(1, parents.size) + assertEquals(1, parents!!.size) assertEquals(spaceName, parents.first().roomSummary?.name) assertNotNull(canonicalParents) - assertEquals(1, canonicalParents.size) + assertEquals(1, canonicalParents!!.size) 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 } assertNotNull(parents) - assertEquals(1, parents.size, "Unexpected number of parent") - assertEquals(spaceName, parents.first().roomSummary?.name, "Unexpected parent name ") - assertEquals(if (it.second) 1 else 0, canonicalParents?.size ?: 0, "Parent of ${it.first} should be canonical ${it.second}") + assertEquals("Unexpected number of parent", 1, parents!!.size) + assertEquals("Unexpected parent name", spaceName, parents.first().roomSummary?.name) + 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) }) - assertEquals(9, allRooms.size, "Unexpected number of rooms") + assertEquals("Unexpected number of rooms", 9, allRooms.size) val orphans = session.getFlattenRoomSummaryChildrenOf(null) - assertEquals(2, orphans.size, "Unexpected number of orphan rooms") - assertTrue(orphans.indexOfFirst { it.roomId == orphan1 } != -1, "O1 should be an orphan") - assertTrue(orphans.indexOfFirst { it.roomId == orphan2 } != -1, "O2 should be an orphan ${orphans.map { it.name }}") + assertEquals("Unexpected number of orphan rooms", 2, orphans.size) + assertTrue("O1 should be an orphan", orphans.any { it.roomId == orphan1 }) + assertTrue("O2 should be an orphan ${orphans.map { it.name }}", orphans.any { it.roomId == orphan2 }) val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId) - assertEquals(4, aChildren.size, "Unexpected number of flatten child rooms") - assertTrue(aChildren.indexOfFirst { it.name == "A1" } != -1, "A1 should be a child of A") - assertTrue(aChildren.indexOfFirst { it.name == "A2" } != -1, "A2 should be a child of A") - assertTrue(aChildren.indexOfFirst { it.name == "C1" } != -1, "CA should be a grand child of A") - assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A") + assertEquals("Unexpected number of flatten child rooms", 4, aChildren.size) + assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" }) + assertTrue("A2 should be a child of A", aChildren.any { it.name == "A2" }) + assertTrue("CA should be a grand child of A", aChildren.any { it.name == "C1" }) + 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 val a3 = runBlocking { @@ -205,7 +205,7 @@ class SpaceHierarchyTest : InstrumentedTest { } 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 @@ -242,11 +242,11 @@ class SpaceHierarchyTest : InstrumentedTest { val aChildren = session.getFlattenRoomSummaryChildrenOf(spaceAInfo.spaceId) - assertEquals(4, aChildren.size, "Unexpected number of flatten child rooms ${aChildren.map { it.name }}") - assertTrue(aChildren.indexOfFirst { it.name == "A1" } != -1, "A1 should be a child of A") - assertTrue(aChildren.indexOfFirst { it.name == "A2" } != -1, "A2 should be a child of A") - assertTrue(aChildren.indexOfFirst { it.name == "C1" } != -1, "CA should be a grand child of A") - assertTrue(aChildren.indexOfFirst { it.name == "C2" } != -1, "A1 should be a grand child of A") + assertEquals("Unexpected number of flatten child rooms ${aChildren.map { it.name }}", 4, aChildren.size) + assertTrue("A1 should be a child of A", aChildren.any { it.name == "A1" }) + assertTrue("A2 should be a child of A", aChildren.any { it.name == "A2" }) + assertTrue("CA should be a grand child of A", aChildren.any { it.name == "C1" }) + assertTrue("A1 should be a grand child of A", aChildren.any { it.name == "C2" }) } @Test @@ -282,9 +282,7 @@ class SpaceHierarchyTest : InstrumentedTest { override fun onChanged(children: List?) { // 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 }}") - if (children?.indexOfFirst { it.name == "C1" } != -1 - && children?.indexOfFirst { it.name == "C2" } != -1 - ) { + if (children?.any { it.name == "C1" } == true && children.any { it.name == "C2" }) { // B1 has been added live! latch.countDown() flatAChildren.removeObserver(this) @@ -409,6 +407,6 @@ class SpaceHierarchyTest : InstrumentedTest { 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) } }