update ktlint plugin to 11.3.1, format code (#3442)
This commit is contained in:
parent
774d79d666
commit
d839f18267
141 changed files with 589 additions and 428 deletions
|
@ -90,13 +90,12 @@ class BottomSheetActivityTest {
|
|||
poll = null,
|
||||
card = null,
|
||||
language = null,
|
||||
filtered = null,
|
||||
filtered = null
|
||||
)
|
||||
private val statusSingle = Single.just(SearchResult(emptyList(), listOf(status), emptyList()))
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
||||
RxJavaPlugins.setIoSchedulerHandler { testScheduler }
|
||||
RxAndroidPlugins.setMainThreadSchedulerHandler { testScheduler }
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class FilterV1Test {
|
|||
expiresAt = null,
|
||||
irreversible = false,
|
||||
wholeWord = false
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
filterModel.initWithFilters(filters)
|
||||
|
@ -191,7 +191,7 @@ class FilterV1Test {
|
|||
mockStatus(
|
||||
content = "should not be filtered",
|
||||
spoilerText = "should not be filtered",
|
||||
attachmentsDescriptions = listOf("should not be filtered", "badWord"),
|
||||
attachmentsDescriptions = listOf("should not be filtered", "badWord")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -314,7 +314,9 @@ class FilterV1Test {
|
|||
)
|
||||
}
|
||||
)
|
||||
} else arrayListOf(),
|
||||
} else {
|
||||
arrayListOf()
|
||||
},
|
||||
mentions = listOf(),
|
||||
tags = listOf(),
|
||||
application = null,
|
||||
|
@ -334,10 +336,12 @@ class FilterV1Test {
|
|||
voted = false,
|
||||
ownVotes = null
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
card = null,
|
||||
language = null,
|
||||
filtered = null,
|
||||
filtered = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,14 +29,17 @@ class FocalPointUtilTest {
|
|||
fun positiveFocalXToCoordinateTest() {
|
||||
assertEquals(FocalPointUtil.focalXToCoordinate(0.4f), 0.7f, eps)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun negativeFocalXToCoordinateTest() {
|
||||
assertEquals(FocalPointUtil.focalXToCoordinate(-0.8f), 0.1f, eps)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun positiveFocalYToCoordinateTest() {
|
||||
assertEquals(FocalPointUtil.focalYToCoordinate(-0.2f), 0.6f, eps)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun negativeFocalYToCoordinateTest() {
|
||||
assertEquals(FocalPointUtil.focalYToCoordinate(0.0f), 0.5f, eps)
|
||||
|
@ -47,25 +50,33 @@ class FocalPointUtilTest {
|
|||
fun isVerticalCropTest() {
|
||||
assertTrue(
|
||||
FocalPointUtil.isVerticalCrop(
|
||||
2f, 1f,
|
||||
1f, 2f
|
||||
2f,
|
||||
1f,
|
||||
1f,
|
||||
2f
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isHorizontalCropTest() {
|
||||
assertFalse(
|
||||
FocalPointUtil.isVerticalCrop(
|
||||
1f, 2f,
|
||||
2f, 1f
|
||||
1f,
|
||||
2f,
|
||||
2f,
|
||||
1f
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isPerfectFitTest() { // Doesn't matter what it returns, just check it doesn't crash
|
||||
FocalPointUtil.isVerticalCrop(
|
||||
3f, 1f,
|
||||
6f, 2f
|
||||
3f,
|
||||
1f,
|
||||
6f,
|
||||
2f
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -74,60 +85,83 @@ class FocalPointUtilTest {
|
|||
fun perfectFitScaleDownTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
2f, 5f,
|
||||
5f, 12.5f
|
||||
2f,
|
||||
5f,
|
||||
5f,
|
||||
12.5f
|
||||
),
|
||||
0.4f, eps
|
||||
0.4f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun perfectFitScaleUpTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
2f, 5f,
|
||||
1f, 2.5f
|
||||
2f,
|
||||
5f,
|
||||
1f,
|
||||
2.5f
|
||||
),
|
||||
2f, eps
|
||||
2f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verticalCropScaleUpTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
2f, 1f,
|
||||
1f, 2f
|
||||
2f,
|
||||
1f,
|
||||
1f,
|
||||
2f
|
||||
),
|
||||
2f, eps
|
||||
2f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verticalCropScaleDownTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
4f, 3f,
|
||||
8f, 24f
|
||||
4f,
|
||||
3f,
|
||||
8f,
|
||||
24f
|
||||
),
|
||||
0.5f, eps
|
||||
0.5f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun horizontalCropScaleUpTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
1f, 2f,
|
||||
2f, 1f
|
||||
1f,
|
||||
2f,
|
||||
2f,
|
||||
1f
|
||||
),
|
||||
2f, eps
|
||||
2f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun horizontalCropScaleDownTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.calculateScaling(
|
||||
3f, 4f,
|
||||
24f, 8f
|
||||
3f,
|
||||
4f,
|
||||
24f,
|
||||
8f
|
||||
),
|
||||
0.5f, eps
|
||||
0.5f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -136,21 +170,26 @@ class FocalPointUtilTest {
|
|||
fun toLowFocalOffsetTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.focalOffset(2f, 8f, 1f, 0.05f),
|
||||
0f, eps
|
||||
0f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toHighFocalOffsetTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.focalOffset(2f, 4f, 2f, 0.95f),
|
||||
-6f, eps
|
||||
-6f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun possibleFocalOffsetTest() {
|
||||
assertEquals(
|
||||
FocalPointUtil.focalOffset(2f, 4f, 2f, 0.7f),
|
||||
-4.6f, eps
|
||||
-4.6f,
|
||||
eps
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class MainActivityTest {
|
|||
note = "",
|
||||
url = "",
|
||||
avatar = "",
|
||||
header = "",
|
||||
header = ""
|
||||
)
|
||||
private val accountEntity = AccountEntity(
|
||||
id = 1,
|
||||
|
@ -104,7 +104,7 @@ class MainActivityTest {
|
|||
avatar = "https://mastodon.example/system/accounts/avatars/000/150/486/original/ab27d7ddd18a10ea.jpg"
|
||||
),
|
||||
status = null,
|
||||
report = null,
|
||||
report = null
|
||||
),
|
||||
accountEntity,
|
||||
true
|
||||
|
|
|
@ -29,7 +29,7 @@ class StringUtilsTest {
|
|||
"ab" to "abc",
|
||||
"cb" to "abc",
|
||||
"1" to "2",
|
||||
"abc" to "abc",
|
||||
"abc" to "abc"
|
||||
)
|
||||
lessList.forEach { (l, r) -> assertTrue("$l < $r", l.isLessThanOrEqual(r)) }
|
||||
val notLessList = lessList.filterNot { (l, r) -> l == r }.map { (l, r) -> r to l }
|
||||
|
|
|
@ -74,7 +74,6 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should return error when network call returns error code`() {
|
||||
|
||||
val remoteMediator = CachedTimelineRemoteMediator(
|
||||
accountManager = accountManager,
|
||||
api = mock {
|
||||
|
@ -94,7 +93,6 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should return error when network call fails`() {
|
||||
|
||||
val remoteMediator = CachedTimelineRemoteMediator(
|
||||
accountManager = accountManager,
|
||||
api = mock {
|
||||
|
@ -113,7 +111,6 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should not prepend statuses`() {
|
||||
|
||||
val remoteMediator = CachedTimelineRemoteMediator(
|
||||
accountManager = accountManager,
|
||||
api = mock(),
|
||||
|
@ -142,11 +139,10 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should refresh and insert placeholder when a whole page with no overlap to existing statuses is loaded`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -198,7 +194,7 @@ class CachedTimelineRemoteMediatorTest {
|
|||
),
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -206,11 +202,10 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should refresh and not insert placeholder when less than a whole page is loaded`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -259,7 +254,7 @@ class CachedTimelineRemoteMediatorTest {
|
|||
mockStatusEntityWithAccount("5"),
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -267,11 +262,10 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should refresh and not insert placeholders when there is overlap with existing statuses`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -320,7 +314,7 @@ class CachedTimelineRemoteMediatorTest {
|
|||
mockStatusEntityWithAccount("4"),
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -328,7 +322,6 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should not try to refresh already cached statuses when db is empty`() {
|
||||
|
||||
val remoteMediator = CachedTimelineRemoteMediator(
|
||||
accountManager = accountManager,
|
||||
api = mock {
|
||||
|
@ -371,11 +364,10 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should remove deleted status from db and keep state of other cached statuses`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("3", expanded = true),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1", expanded = false),
|
||||
mockStatusEntityWithAccount("1", expanded = false)
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -422,12 +414,11 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should not remove placeholder in timeline`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("8"),
|
||||
mockStatusEntityWithAccount("7"),
|
||||
mockPlaceholderEntityWithAccount("6"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -474,7 +465,7 @@ class CachedTimelineRemoteMediatorTest {
|
|||
mockStatusEntityWithAccount("8"),
|
||||
mockStatusEntityWithAccount("7"),
|
||||
mockPlaceholderEntityWithAccount("6"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -482,11 +473,10 @@ class CachedTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should append statuses`() {
|
||||
|
||||
val statusesAlreadyInDb = listOf(
|
||||
mockStatusEntityWithAccount("8"),
|
||||
mockStatusEntityWithAccount("7"),
|
||||
mockStatusEntityWithAccount("5"),
|
||||
mockStatusEntityWithAccount("5")
|
||||
)
|
||||
|
||||
db.insert(statusesAlreadyInDb)
|
||||
|
@ -527,7 +517,7 @@ class CachedTimelineRemoteMediatorTest {
|
|||
mockStatusEntityWithAccount("5"),
|
||||
mockStatusEntityWithAccount("3"),
|
||||
mockStatusEntityWithAccount("2"),
|
||||
mockStatusEntityWithAccount("1"),
|
||||
mockStatusEntityWithAccount("1")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should return error when network call returns error code`() {
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
on { statusData } doReturn mutableListOf()
|
||||
onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doReturn Response.error(500, "".toResponseBody())
|
||||
|
@ -65,7 +64,6 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
@Test
|
||||
@ExperimentalPagingApi
|
||||
fun `should return error when network call fails`() {
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
on { statusData } doReturn mutableListOf()
|
||||
onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doThrow IOException()
|
||||
|
@ -94,7 +92,8 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
mockStatus("5")
|
||||
),
|
||||
Headers.headersOf(
|
||||
"Link", "<https://mastodon.example/api/v1/favourites?limit=20&max_id=4>; rel=\"next\", <https://mastodon.example/api/v1/favourites?limit=20&min_id=8>; rel=\"prev\""
|
||||
"Link",
|
||||
"<https://mastodon.example/api/v1/favourites?limit=20&max_id=4>; rel=\"next\", <https://mastodon.example/api/v1/favourites?limit=20&min_id=8>; rel=\"prev\""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -116,7 +115,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val newStatusData = mutableListOf(
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("6"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
)
|
||||
|
||||
verify(timelineViewModel).nextKey = "4"
|
||||
|
@ -131,7 +130,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val statuses: MutableList<StatusViewData> = mutableListOf(
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
|
@ -154,7 +153,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
data = listOf(
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
),
|
||||
prevKey = null,
|
||||
nextKey = "0"
|
||||
|
@ -169,7 +168,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
mockStatusViewData("4"),
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
|
||||
assertTrue(result is RemoteMediator.MediatorResult.Success)
|
||||
|
@ -183,7 +182,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val statuses: MutableList<StatusViewData> = mutableListOf(
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
|
@ -206,7 +205,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
data = listOf(
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
),
|
||||
prevKey = null,
|
||||
nextKey = "0"
|
||||
|
@ -222,7 +221,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
StatusViewData.Placeholder("7", false),
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
|
||||
assertTrue(result is RemoteMediator.MediatorResult.Success)
|
||||
|
@ -236,7 +235,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val statuses: MutableList<StatusViewData> = mutableListOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
)
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
|
@ -259,7 +258,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
data = listOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
),
|
||||
prevKey = null,
|
||||
nextKey = "3"
|
||||
|
@ -275,7 +274,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
mockStatusViewData("5"),
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
|
||||
assertTrue(result is RemoteMediator.MediatorResult.Success)
|
||||
|
@ -289,7 +288,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val statuses: MutableList<StatusViewData> = mutableListOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
)
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
|
@ -302,7 +301,8 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
mockStatus("1")
|
||||
),
|
||||
Headers.headersOf(
|
||||
"Link", "<https://mastodon.example/api/v1/favourites?limit=20&max_id=0>; rel=\"next\", <https://mastodon.example/api/v1/favourites?limit=20&min_id=4>; rel=\"prev\""
|
||||
"Link",
|
||||
"<https://mastodon.example/api/v1/favourites?limit=20&max_id=0>; rel=\"next\", <https://mastodon.example/api/v1/favourites?limit=20&min_id=4>; rel=\"prev\""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
data = listOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
),
|
||||
prevKey = null,
|
||||
nextKey = "3"
|
||||
|
@ -331,7 +331,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
mockStatusViewData("5"),
|
||||
mockStatusViewData("3"),
|
||||
mockStatusViewData("2"),
|
||||
mockStatusViewData("1"),
|
||||
mockStatusViewData("1")
|
||||
)
|
||||
verify(timelineViewModel).nextKey = "0"
|
||||
assertTrue(result is RemoteMediator.MediatorResult.Success)
|
||||
|
@ -345,7 +345,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
val statuses: MutableList<StatusViewData> = mutableListOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
)
|
||||
|
||||
val timelineViewModel: NetworkTimelineViewModel = mock {
|
||||
|
@ -361,7 +361,7 @@ class NetworkTimelineRemoteMediatorTest {
|
|||
data = listOf(
|
||||
mockStatusViewData("8"),
|
||||
mockStatusViewData("7"),
|
||||
mockStatusViewData("5"),
|
||||
mockStatusViewData("5")
|
||||
),
|
||||
prevKey = null,
|
||||
nextKey = null
|
||||
|
|
|
@ -54,7 +54,7 @@ fun mockStatus(
|
|||
poll = null,
|
||||
card = null,
|
||||
language = null,
|
||||
filtered = null,
|
||||
filtered = null
|
||||
)
|
||||
|
||||
fun mockStatusViewData(
|
||||
|
@ -110,7 +110,7 @@ fun mockStatusEntityWithAccount(
|
|||
|
||||
fun mockPlaceholderEntityWithAccount(
|
||||
id: String,
|
||||
userId: Long = 1,
|
||||
userId: Long = 1
|
||||
): TimelineStatusWithAccount {
|
||||
return TimelineStatusWithAccount(
|
||||
status = Placeholder(id, false).toEntity(userId)
|
||||
|
|
|
@ -146,7 +146,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true)
|
||||
),
|
||||
detailedStatusPosition = 0,
|
||||
revealButton = RevealButtonState.NO_BUTTON,
|
||||
revealButton = RevealButtonState.NO_BUTTON
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -208,7 +208,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", isExpanded = true)
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.HIDE,
|
||||
revealButton = RevealButtonState.HIDE
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -232,7 +232,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -256,7 +256,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -280,7 +280,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test", bookmarked = false)
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -303,7 +303,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "2", inReplyToId = "1", inReplyToAccountId = "1", isDetailed = true, spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -330,7 +330,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -357,7 +357,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
@ -384,7 +384,7 @@ class ViewThreadViewModelTest {
|
|||
mockStatusViewData(id = "3", inReplyToId = "2", inReplyToAccountId = "1", spoilerText = "Test")
|
||||
),
|
||||
detailedStatusPosition = 1,
|
||||
revealButton = RevealButtonState.REVEAL,
|
||||
revealButton = RevealButtonState.REVEAL
|
||||
),
|
||||
viewModel.uiState.first()
|
||||
)
|
||||
|
|
|
@ -65,7 +65,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun cleanup() = runBlocking {
|
||||
|
||||
val statusesBeforeCleanup = listOf(
|
||||
makeStatus(statusId = 100),
|
||||
makeStatus(statusId = 10, authorServerId = "3"),
|
||||
|
@ -80,7 +79,7 @@ class TimelineDaoTest {
|
|||
makeStatus(statusId = 100),
|
||||
makeStatus(statusId = 10, authorServerId = "3"),
|
||||
makeStatus(statusId = 8, reblog = true, authorServerId = "10"),
|
||||
makeStatus(statusId = 2, accountId = 2, authorServerId = "5"),
|
||||
makeStatus(statusId = 2, accountId = 2, authorServerId = "5")
|
||||
)
|
||||
|
||||
for ((status, author, reblogAuthor) in statusesBeforeCleanup) {
|
||||
|
@ -123,7 +122,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun overwriteDeletedStatus() = runBlocking {
|
||||
|
||||
val oldStatuses = listOf(
|
||||
makeStatus(statusId = 3),
|
||||
makeStatus(statusId = 2),
|
||||
|
@ -217,7 +215,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun deleteAllForInstance() = runBlocking {
|
||||
|
||||
val statusWithRedDomain1 = makeStatus(
|
||||
statusId = 15,
|
||||
accountId = 1,
|
||||
|
@ -283,7 +280,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun `should return correct topId`() = runBlocking {
|
||||
|
||||
val statusData = listOf(
|
||||
makeStatus(
|
||||
statusId = 4,
|
||||
|
@ -318,7 +314,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun `should return correct placeholderId after other ids`() = runBlocking {
|
||||
|
||||
val statusData = listOf(
|
||||
makeStatus(statusId = 1000),
|
||||
makePlaceholder(id = 99),
|
||||
|
@ -345,7 +340,6 @@ class TimelineDaoTest {
|
|||
|
||||
@Test
|
||||
fun `should return correct top placeholderId`() = runBlocking {
|
||||
|
||||
val statusData = listOf(
|
||||
makeStatus(statusId = 1000),
|
||||
makePlaceholder(id = 99),
|
||||
|
@ -398,7 +392,7 @@ class TimelineDaoTest {
|
|||
createdAt: Long = statusId,
|
||||
authorServerId: String = "20",
|
||||
domain: String = "mastodon.example",
|
||||
cardUrl: String? = null,
|
||||
cardUrl: String? = null
|
||||
): Triple<TimelineStatusEntity, TimelineAccountEntity, TimelineAccountEntity?> {
|
||||
val author = TimelineAccountEntity(
|
||||
serverId = authorServerId,
|
||||
|
@ -424,7 +418,9 @@ class TimelineDaoTest {
|
|||
emojis = "[]",
|
||||
bot = false
|
||||
)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val card = when (cardUrl) {
|
||||
null -> null
|
||||
|
@ -465,7 +461,7 @@ class TimelineDaoTest {
|
|||
pinned = false,
|
||||
card = card,
|
||||
language = null,
|
||||
filtered = null,
|
||||
filtered = null
|
||||
)
|
||||
return Triple(status, author, reblogAuthor)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ class InstanceSwitchAuthInterceptorTest {
|
|||
|
||||
@Test
|
||||
fun `should make regular request when requested`() {
|
||||
|
||||
mockWebServer.enqueue(MockResponse())
|
||||
|
||||
val accountManager: AccountManager = mock {
|
||||
|
|
|
@ -30,7 +30,6 @@ class TimelineCasesTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
||||
api = mock()
|
||||
eventHub = EventHub()
|
||||
timelineCases = TimelineCases(api, eventHub)
|
||||
|
@ -97,7 +96,7 @@ class TimelineCasesTest {
|
|||
poll = null,
|
||||
card = null,
|
||||
language = null,
|
||||
filtered = null,
|
||||
filtered = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ class LinkHelperTest {
|
|||
|
||||
private val mentions = listOf(
|
||||
Status.Mention("1", "https://example.com/@user", "user", "user"),
|
||||
Status.Mention("2", "https://example.com/@anotherUser", "anotherUser", "anotherUser"),
|
||||
Status.Mention("2", "https://example.com/@anotherUser", "anotherUser", "anotherUser")
|
||||
)
|
||||
private val tags = listOf(
|
||||
HashTag("Tusky", "https://example.com/Tags/Tusky"),
|
||||
HashTag("mastodev", "https://example.com/Tags/mastodev"),
|
||||
HashTag("mastodev", "https://example.com/Tags/mastodev")
|
||||
)
|
||||
|
||||
private val context: Context
|
||||
|
@ -118,7 +118,7 @@ class LinkHelperTest {
|
|||
null,
|
||||
"foo bar baz",
|
||||
"http:/foo.bar",
|
||||
"c:/foo/bar",
|
||||
"c:/foo/bar"
|
||||
).forEach {
|
||||
Assert.assertEquals("", getDomain(it))
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class LinkHelperTest {
|
|||
"example.com",
|
||||
"localhost",
|
||||
"sub.domain.com",
|
||||
"10.45.0.123",
|
||||
"10.45.0.123"
|
||||
).forEach { domain ->
|
||||
listOf(
|
||||
"https://$domain",
|
||||
|
@ -140,7 +140,7 @@ class LinkHelperTest {
|
|||
"https://$domain/foo/bar.html#",
|
||||
"https://$domain/foo/bar.html#anchor",
|
||||
"https://$domain/foo/bar.html?argument=value",
|
||||
"https://$domain/foo/bar.html?argument=value&otherArgument=otherValue",
|
||||
"https://$domain/foo/bar.html?argument=value&otherArgument=otherValue"
|
||||
).forEach { url ->
|
||||
Assert.assertEquals(domain, getDomain(url))
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class LinkHelperTest {
|
|||
"https://www.example.com/foo/bar" to "example.com",
|
||||
"https://awww.example.com/foo/bar" to "awww.example.com",
|
||||
"http://www.localhost" to "localhost",
|
||||
"https://wwwexample.com/" to "wwwexample.com",
|
||||
"https://wwwexample.com/" to "wwwexample.com"
|
||||
).forEach { (url, domain) ->
|
||||
Assert.assertEquals(domain, getDomain(url))
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class LinkHelperTest {
|
|||
"Another Place: another.place/",
|
||||
"Another Place - https://another.place",
|
||||
"Another Place | https://another.place/",
|
||||
"Another Place https://another.place/path",
|
||||
"Another Place https://another.place/path"
|
||||
)
|
||||
asserts.forEach {
|
||||
Assert.assertTrue(markedUpContent.contains(context.getString(R.string.url_domain_notifier, it, "some.place")))
|
||||
|
@ -367,7 +367,7 @@ class LinkHelperTest {
|
|||
arrayOf("https://pixelfed.social/connyduck", true),
|
||||
arrayOf("https://gts.foo.bar/@goblin/statuses/01GH9XANCJ0TA8Y95VE9H3Y0Q2", true),
|
||||
arrayOf("https://gts.foo.bar/@goblin", true),
|
||||
arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true),
|
||||
arrayOf("https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5", true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class LocaleUtilsTest {
|
|||
clientId = null,
|
||||
clientSecret = null,
|
||||
isActive = true,
|
||||
defaultPostLanguage = configuredLanguages[1].orEmpty(),
|
||||
defaultPostLanguage = configuredLanguages[1].orEmpty()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.robolectric.annotation.Config
|
|||
@RunWith(AndroidJUnit4::class)
|
||||
class RickRollTest {
|
||||
private lateinit var activity: Activity
|
||||
|
||||
@Before
|
||||
fun setupActivity() {
|
||||
val controller = Robolectric.buildActivity(Activity::class.java)
|
||||
|
@ -23,12 +24,12 @@ class RickRollTest {
|
|||
@Test
|
||||
fun testShouldRickRoll() {
|
||||
listOf("gab.Com", "social.gab.ai", "whatever.GAB.com").forEach {
|
||||
rollableDomain ->
|
||||
rollableDomain ->
|
||||
assertTrue(shouldRickRoll(activity, rollableDomain))
|
||||
}
|
||||
|
||||
listOf("chaos.social", "notgab.com").forEach {
|
||||
notRollableDomain ->
|
||||
notRollableDomain ->
|
||||
assertFalse(shouldRickRoll(activity, notRollableDomain))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue