|
| 1 | +/* |
| 2 | + * Copyright (c) 2016 Christophe Lafolet |
| 3 | + * |
| 4 | + * This file is part of gstreamer-java. |
| 5 | + * |
| 6 | + * gstreamer-java is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Lesser General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * gstreamer-java is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with gstreamer-java. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | +package org.freedesktop.gstreamer; |
| 20 | + |
| 21 | +import static org.junit.Assert.assertEquals; |
| 22 | + |
| 23 | +import org.freedesktop.gstreamer.lowlevel.GType; |
| 24 | +import org.freedesktop.gstreamer.lowlevel.GstTypes; |
| 25 | +import org.junit.After; |
| 26 | +import org.junit.AfterClass; |
| 27 | +import org.junit.Before; |
| 28 | +import org.junit.BeforeClass; |
| 29 | +import org.junit.Test; |
| 30 | + |
| 31 | +public class GstTypesTest { |
| 32 | + |
| 33 | + public GstTypesTest() { |
| 34 | + } |
| 35 | + |
| 36 | + @BeforeClass |
| 37 | + public static void setUpClass() throws Exception { |
| 38 | + Gst.init("GstTypesTest", new String[] {}); |
| 39 | + } |
| 40 | + |
| 41 | + @AfterClass |
| 42 | + public static void tearDownClass() throws Exception { |
| 43 | + Gst.deinit(); |
| 44 | + } |
| 45 | + |
| 46 | + @Before |
| 47 | + public void setUp() { |
| 48 | + } |
| 49 | + |
| 50 | + @After |
| 51 | + public void tearDown() { |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void registeredClassTest() { |
| 56 | + // check a registered class |
| 57 | + GType elementType = GType.valueOf(Element.GTYPE_NAME); |
| 58 | + assertEquals(Element.class, GstTypes.classFor(elementType)); |
| 59 | + assertEquals(elementType, GstTypes.typeFor(Element.class)); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void unregisteredClassTest() { |
| 64 | + GType elementType = GType.valueOf(Element.GTYPE_NAME); |
| 65 | + // check a unregistered class which derived from Element |
| 66 | + Element anElement = ElementFactory.make("avidemux", "avidemux"); |
| 67 | + assertEquals(Element.class, GstTypes.classFor(anElement.getType())); |
| 68 | + |
| 69 | + // verify GType has not changed for Element.class |
| 70 | + assertEquals(elementType, GstTypes.typeFor(Element.class)); |
| 71 | + } |
| 72 | +} |
| 73 | + |
0 commit comments