[gstreamermm] tests: add one more test for Gst::Query class



commit 789cd8a06351b497eb2dd2902e3300bdeed6c913
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Tue Aug 25 14:12:55 2015 +0000

    tests: add one more test for Gst::Query class
    
        * tests/test-query.cc: some setters in query class must be called with
          writable object. New test checks, if casting between query types
          without loosing writability is possible, and shows, how to do it, if
          someone needs it.

 tests/test-query.cc |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-query.cc b/tests/test-query.cc
index 54ac647..43168d5 100644
--- a/tests/test-query.cc
+++ b/tests/test-query.cc
@@ -79,3 +79,27 @@ TEST(QueryTest, CheckStoringAllocationParams)
   ASSERT_EQ(allocator, allocator2);
   ASSERT_EQ(params.get_align(), params2.get_align());
 }
+
+void ogoloc(Glib::RefPtr<Gst::Query> &query)
+{
+       Glib::RefPtr<Gst::QueryUri> query_uri(static_cast<Gst::QueryUri*>(query.release()));
+
+}
+
+TEST(QueryTest, ShouldCastToAnotherQueryTypeWithoutAdditionalReference)
+{
+  Glib::RefPtr<Gst::Query> query = QueryUri::create();
+  Glib::ustring uri = "file:///some/uri";
+
+  {
+    Glib::RefPtr<Gst::QueryUri> query_uri(static_cast<Gst::QueryUri*>(query.release()));
+    ASSERT_FALSE(query);
+    // QueryUri::set requires writable query object, so query object's refcount has to equal 1
+    ASSERT_TRUE(query_uri->is_writable());
+    query_uri->set(uri);
+    ASSERT_STREQ(uri.c_str(), query_uri->parse().c_str());
+    query = std::move(query_uri);
+    ASSERT_FALSE(query_uri);
+  }
+  ASSERT_EQ(1, query->get_refcount());
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]