Sorts users in switchers by creation time.
This was discovered by QA but is less of a bug and more of a feature request. The new implementation will display the users in creation order with the oldest users first. Fix: 251365125 Test: Manually verified order and also added a unit test Change-Id: Ib3989fc24fa4cfd9bf27936855434edf69670bd4
This commit is contained in:
committed by
Ale Nijamkin
parent
dc6c303983
commit
640931d5f4
@@ -220,7 +220,7 @@ constructor(
|
||||
val result = withContext(backgroundDispatcher) { manager.aliveUsers }
|
||||
|
||||
if (result != null) {
|
||||
_userInfos.value = result
|
||||
_userInfos.value = result.sortedBy { it.creationTime }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,27 @@ class UserRepositoryImplRefactoredTest : UserRepositoryImplTest() {
|
||||
assertThat(underTest.lastSelectedNonGuestUserId).isEqualTo(selectedNonGuestUserId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `refreshUsers - sorts by creation time`() = runSelfCancelingTest {
|
||||
underTest = create(this)
|
||||
val unsortedUsers =
|
||||
setUpUsers(
|
||||
count = 3,
|
||||
selectedIndex = 0,
|
||||
)
|
||||
unsortedUsers[0].creationTime = 900
|
||||
unsortedUsers[1].creationTime = 700
|
||||
unsortedUsers[2].creationTime = 999
|
||||
val expectedUsers = listOf(unsortedUsers[1], unsortedUsers[0], unsortedUsers[2])
|
||||
var userInfos: List<UserInfo>? = null
|
||||
var selectedUserInfo: UserInfo? = null
|
||||
underTest.userInfos.onEach { userInfos = it }.launchIn(this)
|
||||
underTest.selectedUserInfo.onEach { selectedUserInfo = it }.launchIn(this)
|
||||
|
||||
underTest.refreshUsers()
|
||||
assertThat(userInfos).isEqualTo(expectedUsers)
|
||||
}
|
||||
|
||||
private fun setUpUsers(
|
||||
count: Int,
|
||||
hasGuest: Boolean = false,
|
||||
|
||||
Reference in New Issue
Block a user