[gstreamermm: 128/167] wrapped some query "create" methods as static methods of Query class, added unit tests
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 128/167] wrapped some query "create" methods as static methods of Query class, added unit tests
- Date: Tue, 3 Sep 2013 19:29:49 +0000 (UTC)
commit 2f7027439856cb32d153c669946f14040955fd67
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date: Mon Aug 5 02:14:51 2013 +0200
wrapped some query "create" methods as static methods of Query class, added unit tests
.gitignore | 1 +
gstreamer/src/query.hg | 35 +++++++++++++++++++++++++++-
tests/Makefile.am | 6 ++--
tests/test-query.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 97 insertions(+), 4 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 7fe4d45..d8170e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -469,6 +469,7 @@ tests/test-buffer
tests/test-bus
tests/test-caps
tests/test-pad
+tests/test-query
tests/test-structure
tests/test-taglist
diff --git a/gstreamer/src/query.hg b/gstreamer/src/query.hg
index e9ea808..319b0b7 100644
--- a/gstreamer/src/query.hg
+++ b/gstreamer/src/query.hg
@@ -21,6 +21,7 @@
#include <gstreamermm/miniobject.h>
#include <gstreamermm/structure.h>
#include <gstreamermm/format.h>
+#include <gstreamermm/caps.h>
#include <glibmm/arrayhandle.h>
_DEFS(gstreamermm,gst)
@@ -107,7 +108,39 @@ public:
// A copy is taken so that the original is not freed by the wrapper.
#m4 _CONVERSION(`const GstStructure*',`Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
- _WRAP_METHOD(Gst::Structure get_structure() const, gst_query_get_structure)
+ _WRAP_METHOD(Gst::Structure get_structure() const, gst_query_get_structure)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_buffering(Gst::Format format), gst_query_new_buffering)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_allocation(Glib::RefPtr<Gst::Caps> caps, bool need_pool),
gst_query_new_allocation)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_uri(), gst_query_new_uri)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_scheduling(), gst_query_new_scheduling)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_drain(), gst_query_new_drain)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_context(), gst_query_new_context)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_custom(Gst::QueryType type, Glib::RefPtr<Gst::Structure>
structure), gst_query_new_custom)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_convert(Gst::Format format, gint64 value, Gst::Format
dest_format), gst_query_new_convert)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_position(Gst::Format format), gst_query_new_position)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_duration(Gst::Format format), gst_query_new_duration)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_latency(), gst_query_new_latency)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_seeking(Gst::Format format), gst_query_new_seeking)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_formats(), gst_query_new_formats)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_segment(Gst::Format format), gst_query_new_segment)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_caps(Glib::RefPtr<Gst::Caps> filter), gst_query_new_caps)
+
+ _WRAP_METHOD(static Glib::RefPtr<Gst::Query> new_accept_caps(Glib::RefPtr<Gst::Caps> filter),
gst_query_new_accept_caps)
/** Get the Gst::QueryType of the query.
*/
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 26153a9..8693941 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,12 +16,12 @@
gstreamermm_includes = -I$(top_builddir)/gstreamer $(if $(srcdir:.=),-I$(top_srcdir)/gstreamer)
local_libgstreamermm = $(top_builddir)/gstreamer/gstreamermm/libgstreamermm-$(GSTREAMERMM_API_VERSION).la
-AM_CPPFLAGS = -I$(top_builddir) $(gstreamermm_includes) $(GSTREAMERMM_CFLAGS)
+AM_CPPFLAGS = -I$(top_builddir) $(gstreamermm_includes) $(GSTREAMERMM_CFLAGS) -std=c++0x
AM_CXXFLAGS = $(GSTREAMERMM_WXXFLAGS) -g
LDADD = $(GSTREAMERMM_LIBS) $(local_libgstreamermm) -lgtest
check_PROGRAMS = test-caps test-buffer test-bus test-caps test-pad \
- test-structure test-taglist
+ test-query test-structure test-taglist
# Include run of test programs in check:
TESTS = $(check_PROGRAMS)
@@ -29,8 +29,8 @@ TESTS = $(check_PROGRAMS)
test_caps_SOURCES = test-caps.cc main.cc
test_buffer_SOURCES = test-buffer.cc main.cc
test_bus_SOURCES = test-bus.cc main.cc
-test_caps_SOURCES = test-caps.cc main.cc
test_pad_SOURCES = test-pad.cc main.cc
+test_query_SOURCES = test-query.cc main.cc
test_structure_SOURCES = test-structure.cc main.cc
test_taglist_SOURCES = test-taglist.cc main.cc
diff --git a/tests/test-query.cc b/tests/test-query.cc
new file mode 100644
index 0000000..65b711d
--- /dev/null
+++ b/tests/test-query.cc
@@ -0,0 +1,59 @@
+/*
+ * test-query.cc
+ *
+ * Created on: 5 sie 2013
+ * Author: loganek
+ */
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+
+using namespace Gst;
+using Glib::RefPtr;
+
+
+// TODO use std::function instead of c++ pointers - some strange errors occurs
+template<typename RetType, typename QType, QueryType type, typename... Args>
+void CreatingQueryTest(RefPtr<RetType> (*create_method)(Args...) , Args... args)
+{
+ RefPtr<Query> query = create_method(args...);
+
+ ASSERT_TRUE(query);
+
+ RefPtr<QType> query_position = RefPtr<QType>::cast_static(query);
+
+ ASSERT_TRUE(query_position);
+
+ ASSERT_EQ(type, query->get_query_type());
+}
+
+template<typename QType, QueryType type, typename... Args>
+void CreatingQueryTest(Args... args)
+{
+ CreatingQueryTest<QType, QType, type, Args...>(&QType::create, args...);
+}
+
+template<typename QType, QueryType type, typename... Args>
+void CreatingQueryTestStatic(RefPtr<Query> (*create_method)(Args...) , Args... args)
+{
+ CreatingQueryTest<Query, QType, type, Args...>(create_method, args...);
+}
+
+
+TEST(QueryTest, CorrectCreatingQueryBuffering)
+{
+ CreatingQueryTestStatic<QueryBuffering, QUERY_BUFFERING, Format>(&Query::new_buffering, FORMAT_BUFFERS);
+ CreatingQueryTest<QueryBuffering, QUERY_BUFFERING, Format>(FORMAT_BUFFERS);
+}
+
+TEST(QueryTest, CorrectCreatingQueryPosition)
+{
+ CreatingQueryTestStatic<QueryPosition, QUERY_POSITION, Format>(&Query::new_position, FORMAT_PERCENT);
+ CreatingQueryTest<QueryPosition, QUERY_POSITION, Format>(FORMAT_PERCENT);
+}
+
+TEST(QueryTest, CorrectCreatingQueryConvert)
+{
+ CreatingQueryTestStatic<QueryConvert, QUERY_CONVERT, Format, gint64, Format>(&Query::new_convert,
FORMAT_PERCENT, 10, FORMAT_BYTES);
+ CreatingQueryTest<QueryConvert, QUERY_CONVERT, Format, gint64, Format>(FORMAT_PERCENT, 10, FORMAT_BYTES);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]