package com.cottondb.messages.chatimport android.app.Applicationimport android.graphics.Bitmapimport kotlinx.coroutines.runBlockingimport org.junit.Afterimport org.junit.Assert.assertEqualsimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * People's photos in Comms (owner via the coordinator, 24 Nov 2026: display pictures no longer showed in WhatsApp * chats). The core answers a face's photo as its media key (a person's `avatar_key`, a contact's, a group's * `photo_key`); the picture loader opened only `msg:`, `file:` and `uri:` keys, so every such photo fell back to * initials. A plain key is now opened by the core (`media.ensure`). Invented key and picture. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], application = Application::class)classFacePhotoTest { @After fun end() { ChatPictures.media = null } @Test fun a_persons_photo_by_its_media_key_is_opened_by_the_core() = runBlocking {val file = java.io.File.createTempFile("face", ".png")Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_8888).compress(Bitmap.CompressFormat.PNG, 100, file.outputStream())val asked = mutableListOf<String>()ChatPictures.media = { key -> asked += key; file }val key = "db-invented/people/p-asha/whatsapp/3f2a.jpg"// The file then opens as every message picture does (ImageDecoder, which Robolectric does not run).ChatPictures.load(androidx.test.core.app.ApplicationProvider.getApplicationContext(), key, 96, 96) assertEquals("a photo's plain media key is asked of the core, not dropped", listOf(key), asked) }}