Skip to content

Commit be47879

Browse files
committed
correct bug in GstTypes
1 parent 2f09960 commit be47879

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

src/org/freedesktop/gstreamer/lowlevel/GstTypes.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public static final Class<? extends NativeObject> classFor(final GType gType) {
6767
if (GstTypes.logger.isLoggable(Level.FINER)) {
6868
GstTypes.logger.finer("Found type of " + gType + " = " + cls);
6969
}
70-
gtypeNameMap.put(gTypeName, cls);
70+
71+
// The following line is an optimisation but not compatible with current implementation of GstTypes.typeFor()
72+
// Uncomment the following line after refactoring of GstTypes.typeFor()
73+
// gtypeNameMap.put(gTypeName, cls);
74+
7175
return cls;
7276
}
7377
type = type.getParentType();
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)