summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2010-12-08 14:37:24 +0200
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.co.uk>2010-12-11 12:18:50 +0200
commite97f4ecb96be18ca1932de32fbaaa95c266e442d (patch)
treeb64b35aab14ca437c461a26e877bab17eef3309e
parent15c9b1c9c9fefc9335161700f10101ad90e1497e (diff)
Move the refpointer compilation tests to the right place. Finally! :)
-rw-r--r--tests/auto/refpointertest.cpp53
-rw-r--r--tests/compilation/CompilationTests.cmake82
2 files changed, 82 insertions, 53 deletions
diff --git a/tests/auto/refpointertest.cpp b/tests/auto/refpointertest.cpp
index 1d336e9..98e3b4b 100644
--- a/tests/auto/refpointertest.cpp
+++ b/tests/auto/refpointertest.cpp
@@ -28,7 +28,6 @@ private Q_SLOTS:
void refTest2();
void dynamicCastTest();
void messageDynamicCastTest();
- void compilationTest();
};
void RefPointerTest::refTest1()
@@ -82,58 +81,6 @@ void RefPointerTest::messageDynamicCastTest()
QVERIFY(msg.dynamicCast<QGst::EosMessage>().isNull());
}
-static void testMethod(const QGlib::ObjectPtr & obj)
-{
- QVERIFY(!obj.dynamicCast<QGst::Bin>().isNull());
-};
-
-void RefPointerTest::compilationTest()
-{
- //This is mostly a compilation test. If it compiles, it's fine, if it doesn't, there is a problem.
- QGst::BinPtr bin = QGst::Bin::create();
-
- {
- //operator=()
- QGst::ObjectPtr obj = bin;
- QVERIFY(!obj.dynamicCast<QGst::Bin>().isNull());
- }
-
- {
- //copy constructor
- QGst::ObjectPtr obj(bin);
- QVERIFY(!obj.dynamicCast<QGst::Bin>().isNull());
- }
-
- {
- //implicit cast
- testMethod(bin);
- }
-
-#if 0
- {
- QGst::ObjectPtr obj = bin;
- QGst::BinPtr bin2 = obj; //should fail to compile
- }
-#endif
-
- {
- const QGst::ObjectPtr obj = bin;
- (void)obj->name(); //should work
-#if 0
- obj->setName("foo"); //should fail to compile
-#endif
- }
-
- //test staticCast
- {
-#if 0
- QGst::MessagePtr message = bin.staticCast<QGst::Message>(); //should fail to compile
-#endif
- QGst::ElementPtr element = bin.staticCast<QGst::Element>();
- QGst::PipelinePtr pipeline = bin.staticCast<QGst::Pipeline>();
- }
-}
-
QTEST_APPLESS_MAIN(RefPointerTest)
#include "moc_qgsttest.cpp"
diff --git a/tests/compilation/CompilationTests.cmake b/tests/compilation/CompilationTests.cmake
index a55f802..103a3ee 100644
--- a/tests/compilation/CompilationTests.cmake
+++ b/tests/compilation/CompilationTests.cmake
@@ -1,5 +1,21 @@
# This file defines all the compilation tests
+# Copyright (C) 2010 Collabora Ltd.
+# @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
##########
# Tests for testing whether the compilation tests system works as expected.
# If at least one of those tests fails, something is wrong with the cmake scripts.
@@ -12,3 +28,69 @@ cxx_compilation_test(compilation_test_system_test_2 SHOULD_FAIL "
int main(float i) { return foobar; }
")
#########
+
+######### BEGIN RefPointer tests ########
+
+cxx_compilation_test(refpointer_test_casts SHOULD_COMPILE "
+#include <QGst/Pipeline>
+#include <QGst/Message>
+#include <iostream>
+
+static void testMethod(const QGlib::ObjectPtr & obj)
+{
+ std::cout << obj.dynamicCast<QGst::Bin>().isNull();
+};
+
+int main()
+{
+ QGst::BinPtr bin = QGst::Bin::create();
+
+ {
+ //operator=()
+ QGst::ObjectPtr obj = bin;
+ std::cout << obj.dynamicCast<QGst::Bin>().isNull();
+ }
+
+ {
+ //copy constructor
+ QGst::ObjectPtr obj(bin);
+ std::cout << obj.dynamicCast<QGst::Bin>().isNull();
+ }
+
+ {
+ //implicit cast
+ testMethod(bin);
+ }
+
+ {
+ QGst::ElementPtr element = bin.staticCast<QGst::Element>();
+ QGst::PipelinePtr pipeline = bin.staticCast<QGst::Pipeline>();
+ }
+}
+")
+
+
+cxx_compilation_test(refpointer_test_invalid_upcast SHOULD_FAIL "
+#include <QGst/Bin>
+#include <QGst/Message>
+
+int main()
+{
+ QGst::BinPtr bin = QGst::Bin::create();
+ QGst::ObjectPtr obj = bin;
+ QGst::BinPtr bin2 = obj; //upcast not allowed
+}
+")
+
+cxx_compilation_test(refpointer_test_invalid_staticCast SHOULD_FAIL "
+#include <QGst/Bin>
+#include <QGst/Message>
+
+int main()
+{
+ QGst::BinPtr bin = QGst::Bin::create();
+ QGst::MessagePtr message = bin.staticCast<QGst::Message>(); //bin is not a message
+}
+")
+
+######### END RefPointer tests ########