Add poll test for ended polls.

This commit is contained in:
Onuray Sahin 2022-03-11 18:59:27 +03:00
parent 8b08d3db25
commit 7c6167ace9

View File

@ -19,6 +19,7 @@ package org.matrix.android.sdk.session.room.timeline
import org.amshove.kluent.fail
import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeGreaterThan
import org.amshove.kluent.shouldContain
import org.amshove.kluent.shouldContainAll
import org.junit.FixMethodOrder
@ -62,7 +63,7 @@ class PollAggregationTest : InstrumentedTest {
val aliceTimeline = roomFromAlicePOV.createTimeline(null, TimelineSettings(30))
aliceTimeline.start()
val TOTAL_TEST_COUNT = 5
val TOTAL_TEST_COUNT = 6
val lock = CountDownLatch(TOTAL_TEST_COUNT)
val aliceEventsListener = object : Timeline.Listener {
@ -102,6 +103,11 @@ class PollAggregationTest : InstrumentedTest {
TOTAL_TEST_COUNT - 4 -> {
testAliceVotesOption1AndBobVotesOption2(pollContent, pollSummary)
lock.countDown()
roomFromBobPOV.endPoll(pollEventId)
}
TOTAL_TEST_COUNT - 5 -> {
testEndedPoll(pollSummary)
lock.countDown()
}
else -> {
fail("Lock count ${lock.count} didn't handled.")
@ -199,6 +205,10 @@ class PollAggregationTest : InstrumentedTest {
} ?: run { fail("Aggregated poll content shouldn't be null after someone votes") }
}
private fun testEndedPoll(pollSummary: PollResponseAggregatedSummary?) {
pollSummary?.closedTime ?: 0 shouldBeGreaterThan 0
}
private fun assertTotalVotesCount(aggregatedContent: PollSummaryContent, expectedVoteCount: Int) {
aggregatedContent.totalVotes shouldBeEqualTo expectedVoteCount
aggregatedContent.votes?.size shouldBeEqualTo expectedVoteCount