@@ -19,6 +19,7 @@ package org.meshtastic.core.service
1919import android.app.Notification
2020import android.app.NotificationManager
2121import android.content.Context
22+ import androidx.core.app.NotificationCompat
2223import androidx.test.core.app.ApplicationProvider
2324import androidx.test.ext.junit.runners.AndroidJUnit4
2425import dev.mokkery.MockMode
@@ -37,6 +38,7 @@ import org.meshtastic.core.model.ConnectionState
3738import org.meshtastic.core.model.Message
3839import org.meshtastic.core.model.MyNodeInfo
3940import org.meshtastic.core.model.Node
41+ import org.meshtastic.core.model.Reaction
4042import org.meshtastic.core.repository.NodeRepository
4143import org.meshtastic.core.repository.PacketRepository
4244import org.meshtastic.core.repository.RadioConfigRepository
@@ -102,7 +104,22 @@ class MeshNotificationManagerImplConversationTest {
102104 everySuspend { packetRepository.getMessagesFrom(any(), any(), any(), any()) } returns flowOf(messages.toList())
103105 }
104106
105- private fun message (text : String , read : Boolean , receivedTime : Long ): Message = Message (
107+ private fun reaction (emoji : String , timestamp : Long ): Reaction = Reaction (
108+ replyId = 0 ,
109+ user = sender.user,
110+ emoji = emoji,
111+ timestamp = timestamp,
112+ snr = 0f ,
113+ rssi = 0 ,
114+ hopsAway = 0 ,
115+ )
116+
117+ private fun message (
118+ text : String ,
119+ read : Boolean ,
120+ receivedTime : Long ,
121+ emojis : List <Reaction > = emptyList(),
122+ ): Message = Message (
106123 uuid = receivedTime,
107124 receivedTime = receivedTime,
108125 node = sender,
@@ -113,7 +130,7 @@ class MeshNotificationManagerImplConversationTest {
113130 status = null ,
114131 routingError = 0 ,
115132 packetId = receivedTime.toInt(),
116- emojis = emptyList() ,
133+ emojis = emojis ,
117134 snr = 0f ,
118135 rssi = 0 ,
119136 hopsAway = 0 ,
@@ -142,7 +159,7 @@ class MeshNotificationManagerImplConversationTest {
142159 fun `read messages become historic context and unread messages stay alerting` () = runTest {
143160 mockHistory(
144161 message(" new unread" , read = false , receivedTime = 3_000 ),
145- message(" older read 2" , read = true , receivedTime = 2_000 ),
162+ message(" older read 2" , read = true , receivedTime = 2_000 , emojis = listOf (reaction( " 👍 " , 2_100 )) ),
146163 message(" older read 1" , read = true , receivedTime = 1_000 ),
147164 )
148165
@@ -158,7 +175,7 @@ class MeshNotificationManagerImplConversationTest {
158175 val alerting = posted.extras.getParcelableArray(Notification .EXTRA_MESSAGES )
159176 val historic = posted.extras.getParcelableArray(Notification .EXTRA_HISTORIC_MESSAGES )
160177 assertEquals(1 , alerting?.size, " only the unread message should be presented as new content" )
161- assertEquals(2 , historic?.size, " read context should be carried as historic messages" )
178+ assertEquals(3 , historic?.size, " read context and its reactions should be carried as historic messages" )
162179 assertEquals(" new unread" , posted.extras.getCharSequence(Notification .EXTRA_TEXT )?.toString())
163180 }
164181
@@ -170,6 +187,11 @@ class MeshNotificationManagerImplConversationTest {
170187
171188 val summary = activeByTag(" message_summary" ).single().notification
172189 assertEquals(Notification .GROUP_ALERT_CHILDREN , summary.groupAlertBehavior)
190+ val summaryMessage =
191+ NotificationCompat .MessagingStyle .Message
192+ .getMessagesFromBundleArray(summary.extras.getParcelableArray(Notification .EXTRA_MESSAGES ))
193+ .single()
194+ assertEquals(" Hawk Ridge" , summaryMessage.person?.name)
173195
174196 manager.cancelMessageNotification(" 0^all" )
175197
0 commit comments