Debian Codegraph @

tests/test-pad.cc

raw symbols SCIP
1 /*
2 * test-pad.cc
3 *
4 * Created on: Aug 1, 2013
5 * Author: m.kolny
6 */
7
8 #include "mmtest.h"
9 #include <gstreamermm.h>
10
11 using namespace Gst;
12
13 class PadTest : public ::testing::Test
14 {
15 protected:
16 Glib::RefPtr<Pad> pad;
17
18 static Glib::ustring pad_name;
19 static PadDirection pad_direction;
20
21 void CheckPad()
22 {
23 MM_ASSERT_TRUE(pad);
24 EXPECT_EQ(pad_direction, pad->get_direction());
25 ASSERT_STREQ(pad_name.c_str(), pad->get_name().c_str());
26 }
27 };
28
29 PadDirection PadTest::pad_direction = PAD_SINK;
30 Glib::ustring PadTest::pad_name = "simple-pad";
31
32 TEST_F(PadTest, PadCorrectCreatedUsingPadDirection)
33 {
34 pad = Pad::create(pad_name, pad_direction);
35
36 CheckPad();
37 }
38
39 TEST_F(PadTest, PadCorrectCreatedUsingTemplate)
40 {
41 Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create_simple("video/x-raw");
42 caps->set_simple("width", 500);
43 caps->set_simple("framerate", Gst::Fraction(25, 1));
44
45 Glib::RefPtr<PadTemplate> pad_tpl = PadTemplate::create("source-template", pad_direction, PAD_ALWAYS, caps);
46
47 pad = Pad::create(pad_tpl, pad_name);
48
49 CheckPad();
50 }
51
52 TEST_F(PadTest, PadVerifyGetPadTemplateCaps)
53 {
54 Glib::RefPtr<Gst::Caps> caps;
55 {
56 Glib::RefPtr<PadTemplate> pad_tpl =
57 PadTemplate::create("source-template", pad_direction, PAD_ALWAYS, Caps::create_any());
58 caps = Pad::create(pad_tpl, pad_name)->get_pad_template_caps();
59 }
60 ASSERT_EQ(1, caps->get_refcount());
61 }
62
63 TEST_F(PadTest, PadPushVerifyBufferRefcount)
64 {
65 Glib::RefPtr<Gst::Buffer> buffer = Gst::Buffer::create();
66 pad = Pad::create(pad_name, Gst::PAD_SRC);
67
68 ASSERT_EQ(1, buffer->get_refcount());
69 pad->push(std::move(buffer));
70 MM_ASSERT_FALSE(buffer);
71 }
72
73 TEST_F(PadTest, PadEventDefault)
74 {
75 Glib::RefPtr<Gst::Event> event = Gst::EventEos::create();
76 pad = Pad::create(pad_name, pad_direction);
77
78 ASSERT_EQ(1, event->get_refcount());
79 pad->event_default(std::move(event));
80 MM_ASSERT_FALSE(event);
81 }