diff --git a/test/org/freedesktop/gstreamer/PadTest.java b/test/org/freedesktop/gstreamer/PadTest.java index 9ff87856..bece76f7 100644 --- a/test/org/freedesktop/gstreamer/PadTest.java +++ b/test/org/freedesktop/gstreamer/PadTest.java @@ -32,6 +32,8 @@ import org.freedesktop.gstreamer.event.FlushStopEvent; import org.freedesktop.gstreamer.event.TagEvent; +import org.freedesktop.gstreamer.query.AllocationQuery; +import org.freedesktop.gstreamer.query.Query; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -324,4 +326,14 @@ public void addProbe_Idle() { } + @Test + public void addProbe_Query() { + ProbeTester.test(PadProbeType.QUERY_BOTH, info -> { + Query q = info.getQuery(); +// System.out.println(q.getStructure()); + return q instanceof AllocationQuery; + }); + + } + } diff --git a/test/org/freedesktop/gstreamer/ProbeTester.java b/test/org/freedesktop/gstreamer/ProbeTester.java index c8c690c4..a8f9e5c9 100644 --- a/test/org/freedesktop/gstreamer/ProbeTester.java +++ b/test/org/freedesktop/gstreamer/ProbeTester.java @@ -28,24 +28,54 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; -import java.util.function.Function; +import java.util.function.Predicate; /** * Utility class for unit testing API that operates on a Probe. *
* Call {@link ProbeTester#test(Consumer)} and pass a callback which will * perform the test on a PadProbeInfo it is supplied. The callback runs in a Pad - * probe. The buffer is produced by a simple, ephemeral pipeline that is fed by - * a video test source. + * probe. The test uses a simple, ephemeral pipeline that is fed by a video test + * source (or custom pipeline). + *
+ * The callback is a {@link Predicate} and should return false if the input info
+ * doesn't match that required by the test. Test exceptions should be thrown as
+ * normal. This is to allow the probe to be called repeatedly until the input
+ * info matches that expected. If the probe never matches the test will time
+ * out.
*/
public class ProbeTester {
- public static void test(Set
+ * The pipeline is
+ * The pipeline must have a sink element named sink. The probe will be
+ * attached to the sink pad of the sink element.
+ *
+ * @param pipeline custom pipeline with named sink element
+ * @param mask PadProbeType mask to use when attaching probe to sink pad
+ * @param callback probe callback
+ */
+ public static void test(String pipeline, Setvideotestsrc ! fakesink name=sink
. The probe
+ * will be attached to the sink pad of the sink element.
+ *
+ * @param mask PadProbeType mask to use when attaching probe to sink pad
+ * @param callback probe callback
+ */
+ public static void test(Set