package com.foxx.androidcast.media;

/*********************************************************************
 * RgbToNv21Test.java
 * Created at: Sat 16 May 2026 18:50:36 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class RgbToNv21Test
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 41 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	dbe2a7d672c3395ae8624851aa303331d74a9442b4651131d59fdf7ae6171ee8
**********************************************************************/
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class RgbToNv21Test {

    @Test
    public void whitePixelProducesHighLuma() {
        int[] argb = {0xFFFFFFFF, 0, 0, 0xFFFFFFFF};
        byte[] nv21 = RgbToNv21.fromArgb(argb, 2, 2);
        int y = nv21[0] & 0xff;
        assertTrue(y > 220);
    }

    @Test
    public void blackPixelProducesLowLuma() {
        int[] argb = {0xFF000000, 0, 0, 0xFF000000};
        byte[] nv21 = RgbToNv21.fromArgb(argb, 2, 2);
        int y = nv21[0] & 0xff;
        assertEquals(16, y);
    }

    @Test
    public void bufferSizeMatchesNv21Layout() {
        int w = 16;
        int h = 16;
        int[] argb = new int[w * h];
        byte[] nv21 = RgbToNv21.fromArgb(argb, w, h);
        assertEquals(w * h + w * h / 2, nv21.length);
    }
}
