mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-28 02:20:10 +01:00
Fix test compilation
This commit is contained in:
parent
128d3845b9
commit
f64db7f5f3
@ -26,6 +26,8 @@ import org.matrix.android.sdk.api.session.events.model.EventType
|
|||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||||
|
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
||||||
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
internal class UrlsExtractorTest : InstrumentedTest {
|
internal class UrlsExtractorTest : InstrumentedTest {
|
||||||
@ -36,6 +38,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
fun wrongEventTypeTest() {
|
fun wrongEventTypeTest() {
|
||||||
createEvent(body = "https://matrix.org")
|
createEvent(body = "https://matrix.org")
|
||||||
.copy(type = EventType.STATE_ROOM_GUEST_ACCESS)
|
.copy(type = EventType.STATE_ROOM_GUEST_ACCESS)
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.size shouldBeEqualTo 0
|
.size shouldBeEqualTo 0
|
||||||
}
|
}
|
||||||
@ -43,6 +46,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun oneUrlTest() {
|
fun oneUrlTest() {
|
||||||
createEvent(body = "https://matrix.org")
|
createEvent(body = "https://matrix.org")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.let { result ->
|
.let { result ->
|
||||||
result.size shouldBeEqualTo 1
|
result.size shouldBeEqualTo 1
|
||||||
@ -53,6 +57,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun withoutProtocolTest() {
|
fun withoutProtocolTest() {
|
||||||
createEvent(body = "www.matrix.org")
|
createEvent(body = "www.matrix.org")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.size shouldBeEqualTo 0
|
.size shouldBeEqualTo 0
|
||||||
}
|
}
|
||||||
@ -60,6 +65,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun oneUrlWithParamTest() {
|
fun oneUrlWithParamTest() {
|
||||||
createEvent(body = "https://matrix.org?foo=bar")
|
createEvent(body = "https://matrix.org?foo=bar")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.let { result ->
|
.let { result ->
|
||||||
result.size shouldBeEqualTo 1
|
result.size shouldBeEqualTo 1
|
||||||
@ -70,6 +76,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun oneUrlWithParamsTest() {
|
fun oneUrlWithParamsTest() {
|
||||||
createEvent(body = "https://matrix.org?foo=bar&bar=foo")
|
createEvent(body = "https://matrix.org?foo=bar&bar=foo")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.let { result ->
|
.let { result ->
|
||||||
result.size shouldBeEqualTo 1
|
result.size shouldBeEqualTo 1
|
||||||
@ -80,6 +87,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun oneUrlInlinedTest() {
|
fun oneUrlInlinedTest() {
|
||||||
createEvent(body = "Hello https://matrix.org, how are you?")
|
createEvent(body = "Hello https://matrix.org, how are you?")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.let { result ->
|
.let { result ->
|
||||||
result.size shouldBeEqualTo 1
|
result.size shouldBeEqualTo 1
|
||||||
@ -90,6 +98,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
@Test
|
@Test
|
||||||
fun twoUrlsTest() {
|
fun twoUrlsTest() {
|
||||||
createEvent(body = "https://matrix.org https://example.org")
|
createEvent(body = "https://matrix.org https://example.org")
|
||||||
|
.toFakeTimelineEvent()
|
||||||
.let { urlsExtractor.extract(it) }
|
.let { urlsExtractor.extract(it) }
|
||||||
.let { result ->
|
.let { result ->
|
||||||
result.size shouldBeEqualTo 2
|
result.size shouldBeEqualTo 2
|
||||||
@ -105,4 +114,19 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||||||
body = body
|
body = body
|
||||||
).toContent()
|
).toContent()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun Event.toFakeTimelineEvent(): TimelineEvent {
|
||||||
|
return TimelineEvent(
|
||||||
|
root = this,
|
||||||
|
localId = 0L,
|
||||||
|
eventId = "",
|
||||||
|
displayIndex = 0,
|
||||||
|
senderInfo = SenderInfo(
|
||||||
|
userId = "",
|
||||||
|
displayName = null,
|
||||||
|
isUniqueDisplayName = true,
|
||||||
|
avatarUrl = null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user