@@ -11,63 +11,12 @@ import com.nextcloud.talk.chat.ui.model.ChatMessageUi
1111import com.nextcloud.talk.chat.ui.model.MessageStatusIcon
1212import com.nextcloud.talk.chat.ui.model.MessageTypeContent
1313import org.junit.Assert.assertEquals
14- import org.junit.Assert.assertFalse
1514import org.junit.Assert.assertNull
16- import org.junit.Assert.assertTrue
1715import org.junit.Test
1816import java.time.LocalDate
1917
2018class ChatViewModelTest {
2119
22- @Test
23- fun `isPlausibleLastReadMessageId returns true when there is no known real message id yet` () {
24- assertTrue(ChatViewModel .isPlausibleLastReadMessageId(messageId = 158761 , newestKnownRealMessageId = null ))
25- }
26-
27- @Test
28- fun `isPlausibleLastReadMessageId returns true for the newest known real message id itself` () {
29- assertTrue(ChatViewModel .isPlausibleLastReadMessageId(messageId = 158761 , newestKnownRealMessageId = 158761L ))
30- }
31-
32- @Test
33- fun `isPlausibleLastReadMessageId returns true for an older message id` () {
34- assertTrue(ChatViewModel .isPlausibleLastReadMessageId(messageId = 100 , newestKnownRealMessageId = 158761L ))
35- }
36-
37- @Test
38- fun `isPlausibleLastReadMessageId returns true within the buffer above the newest known message id` () {
39- assertTrue(
40- ChatViewModel .isPlausibleLastReadMessageId(
41- messageId = 158761 + 10_000 ,
42- newestKnownRealMessageId = 158761L
43- )
44- )
45- }
46-
47- @Test
48- fun `isPlausibleLastReadMessageId returns false just beyond the buffer above the newest known message id` () {
49- assertFalse(
50- ChatViewModel .isPlausibleLastReadMessageId(
51- messageId = 158761 + 10_000 + 1 ,
52- newestKnownRealMessageId = 158761L
53- )
54- )
55- }
56-
57- @Test
58- fun `isPlausibleLastReadMessageId rejects a hash-derived placeholder id far beyond the real message id space` () {
59- assertFalse(
60- ChatViewModel .isPlausibleLastReadMessageId(messageId = 1_963_726_147 , newestKnownRealMessageId = 158761L )
61- )
62- }
63-
64- @Test
65- fun `isPlausibleLastReadMessageId treats a newest known id of 0 as unknown` () {
66- // A federated conversation's cached lastMessage can carry an id of 0 - a real message id
67- // is never 0, so this must not be treated as a real ceiling near the start of the room.
68- assertTrue(ChatViewModel .isPlausibleLastReadMessageId(messageId = 136556 , newestKnownRealMessageId = 0L ))
69- }
70-
7120 // The unread marker latch: the marker position must only be derived from the visible window
7221 // when the window provably reaches back to the unread boundary — otherwise a window of
7322 // only-unread messages (e.g. after a capped fetch of the newest messages) would place the
0 commit comments