[gstreamermm: 108/167] added Caps tests
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 108/167] added Caps tests
- Date: Tue, 3 Sep 2013 19:28:08 +0000 (UTC)
commit 0675e3f67a0cf44cbe066a808f8fb641fa4a15ed
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date: Thu Aug 1 11:16:41 2013 +0200
added Caps tests
tests/test-caps.cc | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/test-pad.cc | 2 +-
2 files changed, 102 insertions(+), 1 deletions(-)
---
diff --git a/tests/test-caps.cc b/tests/test-caps.cc
new file mode 100644
index 0000000..6ab4250
--- /dev/null
+++ b/tests/test-caps.cc
@@ -0,0 +1,101 @@
+/*
+ * test-caps.cc
+ *
+ * Created on: Aug 1, 2013
+ * Author: m.kolny
+ */
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+
+using namespace Gst;
+
+class CapsTest : public ::testing::Test
+{
+protected:
+ Glib::RefPtr<Caps> caps;
+
+ static int width;
+ static Fraction framerate;
+
+ template<typename T>
+ void MakeAssert(const T& expected, const T& output)
+ {
+ EXPECT_EQ(expected, output);
+ }
+ void MakeAssert(const Fraction& expected, const Fraction& output)
+ {
+ EXPECT_EQ(expected.denom, output.denom);
+ EXPECT_EQ(expected.num, output.num);
+ }
+
+ template<typename T>
+ void CheckCaps(const Glib::ustring& field_name, T expected, int struct_id = 0)
+ {
+ T output;
+ bool ok = caps->get_structure(struct_id).get_field(field_name, output);
+
+ ASSERT_TRUE(ok);
+ MakeAssert(expected, output);
+ }
+};
+
+int CapsTest::width = 500;
+Fraction CapsTest::framerate = Fraction(25, 1);
+
+TEST_F(CapsTest, CapsCreateSimple)
+{
+ caps = Caps::create_simple("video/x-raw");
+
+ ASSERT_TRUE(caps);
+}
+
+TEST_F(CapsTest, CapsCreateUsingStructure)
+{
+ Structure caps_struct("test-struct");
+ caps_struct.set_field("width", width);
+ caps_struct.set_field("framerate", framerate);
+
+ caps = Caps::create(caps_struct);
+
+ CheckCaps("width", width);
+ CheckCaps("framerate", framerate);
+}
+
+TEST_F(CapsTest, AppendStructureToCaps)
+{
+ caps = Caps::create_simple("video/x-raw");
+
+ Structure caps_struct("test-struct");
+ caps_struct.set_field("width", width);
+
+ caps->set_simple("framerate", framerate);
+ caps->append_structure(caps_struct);
+
+ CheckCaps("width", width, 1);
+ CheckCaps("framerate", framerate);
+}
+
+TEST_F(CapsTest, AppendCapsToCaps)
+{
+ caps = Caps::create_simple("video/x-raw");
+ caps->set_simple("framerate", framerate);
+
+ Glib::RefPtr<Caps> new_caps = Caps::create_simple("video/x-raw");
+ new_caps->set_simple("width", width);
+
+ caps->append(new_caps);
+
+ CheckCaps("width", width, 1);
+ CheckCaps("framerate", framerate);
+}
+
+TEST_F(CapsTest, GetNonExistingValue)
+{
+ caps = Caps::create_simple("video/x-raw");
+
+ int output;
+ bool ok = caps->get_structure(0).get_field("nonexisting-value", output);
+
+ ASSERT_FALSE(ok);
+}
diff --git a/tests/test-pad.cc b/tests/test-pad.cc
index 338783c..18ff7c0 100644
--- a/tests/test-pad.cc
+++ b/tests/test-pad.cc
@@ -38,7 +38,7 @@ TEST_F(PadTest, PadCorrectCreatedUsingPadDirection)
TEST_F(PadTest, PadCorrectCreatedUsingTemplate)
{
- Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create_simple("video/x-raw,format=(yuv)");
+ Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create_simple("video/x-raw");
caps->set_simple("width", 500);
caps->set_simple("framerate", Gst::Fraction(25, 1));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]