From a800a837cc96b0738d041992d89f32bc5a039227 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 12 Jul 2022 15:37:47 +0200 Subject: [PATCH] Timeline tests: unignored --- .../TimelinePreviousLastForwardTest.kt | 10 +++---- .../TimelineSimpleBackPaginationTest.kt | 26 ++++--------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt index 7c1a097b24..476cb25f61 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt @@ -17,10 +17,10 @@ package org.matrix.android.sdk.session.room.timeline import androidx.test.filters.LargeTest +import kotlinx.coroutines.runBlocking import org.amshove.kluent.shouldBeFalse import org.amshove.kluent.shouldBeTrue import org.junit.FixMethodOrder -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 @@ -40,7 +40,6 @@ import java.util.concurrent.CountDownLatch @RunWith(JUnit4::class) @FixMethodOrder(MethodSorters.JVM) -@Ignore("This test will be ignored until it is fixed") @LargeTest class TimelinePreviousLastForwardTest : InstrumentedTest { @@ -232,11 +231,12 @@ class TimelinePreviousLastForwardTest : InstrumentedTest { bobTimeline.addListener(eventsListener) bobTimeline.paginate(Timeline.Direction.FORWARDS, 50) - bobTimeline.paginate(Timeline.Direction.FORWARDS, 50) - commonTestHelper.await(lock) bobTimeline.removeAllListeners() - + commonTestHelper.runBlockingTest { + val timelineEvents = bobTimeline.awaitPaginate(Timeline.Direction.FORWARDS, 50) + Timber.v("Number of timelineEvents=${timelineEvents.size}") + } bobTimeline.hasMoreToLoad(Timeline.Direction.FORWARDS).shouldBeFalse() bobTimeline.hasMoreToLoad(Timeline.Direction.BACKWARDS).shouldBeFalse() } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineSimpleBackPaginationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineSimpleBackPaginationTest.kt index 59b3b14532..ca93fdded7 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineSimpleBackPaginationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineSimpleBackPaginationTest.kt @@ -20,7 +20,6 @@ import androidx.test.filters.LargeTest import kotlinx.coroutines.runBlocking import org.amshove.kluent.internal.assertEquals import org.junit.FixMethodOrder -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 @@ -35,11 +34,11 @@ import org.matrix.android.sdk.api.session.room.timeline.Timeline import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings import org.matrix.android.sdk.common.CommonTestHelper.Companion.runCryptoTest import org.matrix.android.sdk.common.TestConstants +import timber.log.Timber @RunWith(JUnit4::class) @FixMethodOrder(MethodSorters.JVM) @LargeTest -@Ignore class TimelineSimpleBackPaginationTest : InstrumentedTest { @Test @@ -68,28 +67,14 @@ class TimelineSimpleBackPaginationTest : InstrumentedTest { val bobTimeline = roomFromBobPOV.timelineService().createTimeline(null, TimelineSettings(30)) bobTimeline.start() - - commonTestHelper.waitWithLatch(timeout = TestConstants.timeOutMillis * 10) { - val listener = object : Timeline.Listener { - - override fun onStateUpdated(direction: Timeline.Direction, state: Timeline.PaginationState) { - if (direction == Timeline.Direction.FORWARDS) { - return - } - if (state.hasMoreToLoad && !state.loading) { - bobTimeline.paginate(Timeline.Direction.BACKWARDS, 30) - } else if (!state.hasMoreToLoad) { - bobTimeline.removeListener(this) - it.countDown() - } - } + commonTestHelper.runBlockingTest { + while (bobTimeline.hasMoreToLoad(Timeline.Direction.BACKWARDS)) { + val timelineEvents = bobTimeline.awaitPaginate(direction = Timeline.Direction.BACKWARDS, 30) + Timber.v("Number of TimelineEvents= ${timelineEvents.size}") } - bobTimeline.addListener(listener) - bobTimeline.paginate(Timeline.Direction.BACKWARDS, 30) } assertEquals(false, bobTimeline.hasMoreToLoad(Timeline.Direction.FORWARDS)) assertEquals(false, bobTimeline.hasMoreToLoad(Timeline.Direction.BACKWARDS)) - val onlySentEvents = runBlocking { bobTimeline.getSnapshot() } @@ -99,7 +84,6 @@ class TimelineSimpleBackPaginationTest : InstrumentedTest { (it.root.content.toModel())?.body?.startsWith(message).orFalse() } assertEquals(numberOfMessagesToSent, onlySentEvents.size) - bobTimeline.dispose() } }