[gstreamermm: 130/167] added appsink test, enableda all test-plugin-* tests (yes, some tests fail...)
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 130/167] added appsink test, enableda all test-plugin-* tests (yes, some tests fail...)
- Date: Tue, 3 Sep 2013 19:29:59 +0000 (UTC)
commit 8ddd17024fc67ea72999f8541d454eba2c6f56af
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date: Mon Aug 5 02:54:52 2013 +0200
added appsink test, enableda all test-plugin-* tests (yes, some tests fail...)
.gitignore | 7 ++-
tests/Makefile.am | 7 ++-
tests/plugins/test-plugin-appsink.cc | 89 ++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index d8170e3..c5bda50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-# wildcard patterns
+ # wildcard patterns
Makefile
Makefile.in
.deps
@@ -473,6 +473,11 @@ tests/test-query
tests/test-structure
tests/test-taglist
+test-plugin-appsink
+test-plugin-appsrc
+test-plugin-pushsrc
+test-plugin-register
+
# tools/
/tools/extra_defs_gen/generate_defs_gst
/tools/extra_defs_gen/generate_plugin_gmmproc_file
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8693941..d64f23a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,7 +21,8 @@ AM_CXXFLAGS = $(GSTREAMERMM_WXXFLAGS) -g
LDADD = $(GSTREAMERMM_LIBS) $(local_libgstreamermm) -lgtest
check_PROGRAMS = test-caps test-buffer test-bus test-caps test-pad \
- test-query test-structure test-taglist
+ test-query test-structure test-taglist test-plugin-appsink \
+ test-plugin-appsrc test-plugin-register test-plugin-pushsrc
# Include run of test programs in check:
TESTS = $(check_PROGRAMS)
@@ -34,3 +35,7 @@ test_query_SOURCES = test-query.cc main.cc
test_structure_SOURCES = test-structure.cc main.cc
test_taglist_SOURCES = test-taglist.cc main.cc
+test_plugin_appsink_SOURCES = plugins/test-plugin-appsink.cc main.cc
+test_plugin_appsrc_SOURCES = plugins/test-plugin-appsrc.cc main.cc
+test_plugin_pushsrc_SOURCES = plugins/test-plugin-pushsrc.cc main.cc
+test_plugin_register_SOURCES = plugins/test-plugin-register.cc main.cc
diff --git a/tests/plugins/test-plugin-appsink.cc b/tests/plugins/test-plugin-appsink.cc
new file mode 100644
index 0000000..1bad5c0
--- /dev/null
+++ b/tests/plugins/test-plugin-appsink.cc
@@ -0,0 +1,89 @@
+/*
+ * test-plugin-appsink.cc
+ *
+ * Created on: 5 sie 2013
+ * Author: loganek
+ */
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+#include <gstreamermm/appsink.h>
+#include <gstreamermm/appsrc.h>
+
+using namespace Gst;
+using Glib::RefPtr;
+
+class AppSinkPluginTest : public ::testing::Test
+{
+protected:
+ RefPtr<Element> source;
+ RefPtr<Element> sink;
+ RefPtr<Pipeline> pipeline;
+
+ void CreatePipelineWithElements()
+ {
+ sink = Gst::ElementFactory::create_element("appsink", "sink");
+ source = ElementFactory::create_element("appsrc", "source");
+
+ ASSERT_TRUE(sink);
+ ASSERT_TRUE(source);
+
+ ASSERT_NO_THROW(pipeline->add(source)->add(sink));
+ ASSERT_NO_THROW(source->link(sink));
+ }
+};
+
+TEST_F(AppSinkPluginTest, CreatePipelineWithAppsink)
+{
+ CreatePipelineWithElements();
+}
+
+TEST_F(AppSinkPluginTest, UseAppSinkDuringDataFlowInPipeline)
+{
+ sink = Gst::ElementFactory::create_element("appsink", "sink");
+ RefPtr<AppSink> appsink = appsink.cast_static(sink);
+ source = ElementFactory::create_element("appsrc", "source");
+ RefPtr<AppSrc> appsrc = appsrc.cast_static(source);
+ pipeline->add(source)->add(sink);
+ source->link(sink);
+
+ pipeline->set_state(STATE_PLAYING);
+
+ std::string data = "hello world";
+ RefPtr<Buffer> buf = Buffer::create(data.length() + 1);
+
+ RefPtr<MapInfo> map_info(new MapInfo());
+ buf->map(map_info, MAP_WRITE);
+ strcpy((char *)map_info->get_data(), data.c_str());
+ buf->unmap(map_info);
+
+ appsrc->push_buffer(buf);
+
+ {
+ State state;
+ StateChangeReturn ret = pipeline->get_state(state, state, 1*Gst::SECOND);
+ ASSERT_EQ(STATE_CHANGE_SUCCESS, ret);
+ }
+
+ RefPtr<Buffer> buf_out;
+ RefPtr<Sample> sample = appsink->pull_sample();
+ ASSERT_TRUE(sample);
+ buf_out = sample->get_buffer();
+ ASSERT_TRUE(buf_out);
+
+ buf_out->map(map_info, MAP_READ);
+ assert(std::string((char *)map_info->get_data()) == data);
+ buf_out->unmap(map_info);
+
+ appsrc->end_of_stream();
+
+ RefPtr<Message> msg = pipeline->get_bus()->poll((MessageType)(MESSAGE_EOS | MESSAGE_ERROR) , 1*SECOND);
+ ASSERT_TRUE(msg);
+ ASSERT_EQ(MESSAGE_EOS, msg->get_message_type());
+
+ pipeline->set_state(STATE_NULL);
+}
+
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]