Debian Codegraph @

tests/integration/test-integration-binplugin.cc

raw symbols SCIP
1 /*
2 * test-integration-binplugin.cc
3 *
4 * Created on: 8 sie 2013
5 * Author: loganek
6 */
7
8 #include "mmtest.h"
9 #include <gstreamermm.h>
10 #include <glibmm/main.h>
11
12 #include "pluginbin.h"
13
14 using namespace Gst;
15 using Glib::RefPtr;
16
17 RefPtr<Glib::MainLoop> mainloop;
18
19 bool on_bus_message(const RefPtr<Bus>&, const Glib::RefPtr<Message>& message)
20 {
21 switch(message->get_message_type())
22 {
23 case MESSAGE_EOS:
24 mainloop->quit();
25 return false;
26 case MESSAGE_ERROR:
27 mainloop->quit();
28 return false;
29 default:
30 break;
31 }
32
33 return true;
34 }
35
36 TEST(IntegrationBinPluginTest, DISABLED_ShouldDecodeAndEncodeFile)
37 {
38 Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR, "pluginbin",
39 "pluginbin is example of C++ element", sigc::ptr_fun(&PluginBin::register_pluginbin), "0.1",
40 "LGPL", "source?", "package?", "http://example.com");
41
42 Glib::ustring input_png = "resources/input-image.png",
43 output_jpg = "resources/test-integration-binplugin-output-image.jpg";
44
45 mainloop = Glib::MainLoop::create();
46 MM_ASSERT_TRUE(mainloop);
47 RefPtr<Element> pluginbin = Gst::ElementFactory::create_element("pluginbin", "sample-pluginbin");
48 MM_ASSERT_TRUE(pluginbin);
49 RefPtr<Element> jpg_encoder = ElementFactory::create_element("queue");
50 MM_ASSERT_TRUE(jpg_encoder);
51 RefPtr<Element> file_sink = ElementFactory::create_element("filesink", "file-sink");
52 MM_ASSERT_TRUE(file_sink);
53 RefPtr<Pipeline> pipeline = Pipeline::create("image-converter-pipeline");
54 MM_ASSERT_TRUE(pipeline);
55
56 ASSERT_NO_THROW(pipeline->add(pluginbin)->add(jpg_encoder)->add(file_sink));
57 ASSERT_NO_THROW(pluginbin->link(jpg_encoder)->link(file_sink));
58
59 Glib::RefPtr<Gst::Bus> bus = pipeline->get_bus();
60 MM_ASSERT_TRUE(bus);
61 bus->add_watch(sigc::ptr_fun(&on_bus_message));
62
63 pluginbin->set_property("location", input_png);
64 file_sink->set_property("location", output_jpg);
65
66 pipeline->set_state(STATE_PLAYING);
67 mainloop->run();
68
69 pipeline->set_state(Gst::STATE_NULL);
70
71 struct stat st;
72 stat(output_jpg.c_str(), &st);
73 MM_ASSERT_TRUE( st.st_size > 0 ); // weak checking
74 }