package com.peachpasswords.ui.components import org.junit.Assert.assertArrayEquals import org.junit.Assert.assertNull import org.junit.Test class FaviconsTest { @Test fun unwraps_png_inside_ico_container() { val png = byteArrayOf(0x89.toByte(), 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 1, 2, 3) val ico = ByteArray(22 + png.size) ico[2] = 1 // ICO type ico[18] = 22 // data offset, little-endian png.copyInto(ico, 22) assertArrayEquals(png, decodeOrUnwrapIco(ico)) } @Test fun passes_non_ico_bytes_through_and_rejects_ico_without_png() { val png = byteArrayOf(0x89.toByte(), 0x50, 0x4E, 0x47, 1, 2, 3) assertArrayEquals(png, decodeOrUnwrapIco(png)) val icoBmp = ByteArray(22 + 4) icoBmp[2] = 1 icoBmp[18] = 22 assertNull(decodeOrUnwrapIco(icoBmp)) } }