[gstreamermm: 146/167] refactoring



commit 2f30714d5c6b1735375d3915266f40d8251c58a7
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date:   Wed Aug 7 00:34:11 2013 +0200

    refactoring

 tests/test-query.cc |   50 +++++++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/tests/test-query.cc b/tests/test-query.cc
index 949301e..4e47819 100644
--- a/tests/test-query.cc
+++ b/tests/test-query.cc
@@ -7,53 +7,53 @@
 
 #include <gtest/gtest.h>
 #include <gstreamermm.h>
+#include <functional>
 
 using namespace Gst;
 using Glib::RefPtr;
 
-
-// TODO use std::function instead of c++ pointers - some strange errors occurs
-template<typename RetType, typename QType, QueryType type, typename... Args>
-void CreatingQueryTest(RefPtr<RetType> (*create_method)(Args...) , Args... args)
+template<typename QType>
+void CreatingQueryTest(std::function<RefPtr<QType>()> create_method, QueryType type)
 {
-    RefPtr<Query> query = create_method(args...);
+    RefPtr<QType> query = create_method();
 
     ASSERT_TRUE(query);
-
-    RefPtr<QType> query_position = RefPtr<QType>::cast_static(query);
-
-    ASSERT_TRUE(query_position);
-
     ASSERT_EQ(type, query->get_query_type());
 }
 
-template<typename QType, QueryType type, typename... Args>
-void CreatingQueryTest(Args... args)
+template<typename QType>
+void CreatingQueryTestStatic(std::function<RefPtr<Query>()> create_method, QueryType type)
 {
-    CreatingQueryTest<QType, QType, type, Args...>(&QType::create, args...);
-}
+    RefPtr<Query> query = create_method();
 
-template<typename QType, QueryType type, typename... Args>
-void CreatingQueryTestStatic(RefPtr<Query> (*create_method)(Args...) , Args... args)
-{
-    CreatingQueryTest<Query, QType, type, Args...>(create_method, args...);
-}
+    ASSERT_TRUE(query);
+    ASSERT_EQ(type, query->get_query_type());
 
+    RefPtr<QType> query_position = RefPtr<QType>::cast_static(query);
+
+    ASSERT_TRUE(query_position);
+}
 
 TEST(QueryTest, CorrectCreatingQueryBuffering)
 {
-    CreatingQueryTestStatic<QueryBuffering, QUERY_BUFFERING, Format>(&Query::create_buffering, 
FORMAT_BUFFERS);
-    CreatingQueryTest<QueryBuffering, QUERY_BUFFERING, Format>(FORMAT_BUFFERS);
+    CreatingQueryTestStatic<QueryBuffering>(
+            std::bind(&Query::create_buffering, FORMAT_BUFFERS), QUERY_BUFFERING);
+    CreatingQueryTest<QueryBuffering>(
+            std::bind(&QueryBuffering::create, FORMAT_BUFFERS), QUERY_BUFFERING);
 }
 
 TEST(QueryTest, CorrectCreatingQueryPosition)
 {
-    CreatingQueryTestStatic<QueryPosition, QUERY_POSITION, Format>(&Query::create_position, FORMAT_PERCENT);
-    CreatingQueryTest<QueryPosition, QUERY_POSITION, Format>(FORMAT_PERCENT);
+    CreatingQueryTestStatic<QueryPosition>(
+            std::bind(&Query::create_position, FORMAT_PERCENT), QUERY_POSITION);
+    CreatingQueryTest<QueryPosition>(
+            std::bind(&QueryPosition::create, FORMAT_PERCENT), QUERY_POSITION);
 }
 
 TEST(QueryTest, CorrectCreatingQueryConvert)
 {
-    CreatingQueryTestStatic<QueryConvert, QUERY_CONVERT, Format, gint64, Format>(&Query::create_convert, 
FORMAT_PERCENT, 10, FORMAT_BYTES);
-    CreatingQueryTest<QueryConvert, QUERY_CONVERT, Format, gint64, Format>(FORMAT_PERCENT, 10, FORMAT_BYTES);
+    CreatingQueryTestStatic<QueryConvert>(
+            std::bind(&Query::create_convert, FORMAT_PERCENT, 10, FORMAT_BYTES), QUERY_CONVERT);
+    CreatingQueryTest<QueryConvert>(
+            std::bind(&QueryConvert::create, FORMAT_PERCENT, 10, FORMAT_BYTES), QUERY_CONVERT);
 }


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