|
| 1 | +package net.bramp.ffmpeg.adapter; |
| 2 | + |
| 3 | +import com.google.gson.Gson; |
| 4 | +import com.google.gson.GsonBuilder; |
| 5 | +import net.bramp.ffmpeg.probe.FFmpegStream; |
| 6 | +import org.junit.BeforeClass; |
| 7 | +import org.junit.Test; |
| 8 | + |
| 9 | +import static org.junit.Assert.assertEquals; |
| 10 | + |
| 11 | +public class FFmpegStreamSideDataAdapterTest { |
| 12 | + static Gson gson; |
| 13 | + @BeforeClass |
| 14 | + public static void setGson() { |
| 15 | + GsonBuilder builder = new GsonBuilder(); |
| 16 | + builder.registerTypeAdapter(FFmpegStream.SideData.class, new FFmpegStreamSideDataAdapter()); |
| 17 | + gson = builder.create(); |
| 18 | + } |
| 19 | + |
| 20 | + @Test |
| 21 | + public void testNumberFormatException() { |
| 22 | + FFmpegStream.SideData sideData = gson.fromJson("{\"side_data_type\": \"Display Matrix\", \"displaymatrix\": \"\n00000000: 0 0 0\n00000001: 0 0 0\n00000002: 0 0 1073741824\n\", \"rotation\": -9223372036854775808}", FFmpegStream.SideData.class); |
| 23 | + assertEquals(sideData.side_data_type, "Display Matrix"); |
| 24 | + assertEquals(sideData.displaymatrix, "\n00000000: 0 0 0\n00000001: 0 0 0\n00000002: 0 0 1073741824\n"); |
| 25 | + assertEquals(sideData.rotation, 0); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testNormalVideo() { |
| 30 | + FFmpegStream.SideData sideData = gson.fromJson("{\"side_data_type\": \"Display Matrix\", \"displaymatrix\": \"\n00000000: 0 -65536 0\n00000001: 65536 0 0\n00000002: 0 0 1073741824\n\", \"rotation\": 90}", FFmpegStream.SideData.class); |
| 31 | + assertEquals(sideData.side_data_type, "Display Matrix"); |
| 32 | + assertEquals(sideData.displaymatrix, "\n00000000: 0 -65536 0\n00000001: 65536 0 0\n00000002: 0 0 1073741824\n"); |
| 33 | + assertEquals(sideData.rotation, 90); |
| 34 | + } |
| 35 | + |
| 36 | +} |
0 commit comments