1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
# 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 Lesser 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.
cxx_compilation_test(compilation_test_system_test_1 SHOULD_COMPILE "
int main() { return 0; }
")
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
}
")
cxx_compilation_test(refpointer_test_integral_cast SHOULD_FAIL "
#include <QGlib/Object>
#include <iostream>
void func(int b) { std::cout << b; }
int main()
{
QGlib::ObjectPtr ptr;
func(ptr);
}
")
cxx_compilation_test(refpointer_test_bool_cast SHOULD_COMPILE "
#include <QGlib/Object>
#include <iostream>
int main()
{
QGlib::ObjectPtr ptr;
if (ptr) {
std::cout << \"foo\";
}
}
")
######### END RefPointer tests ########
######### BEGIN disconnect tests ########
cxx_compilation_test(disconnect_full SHOULD_COMPILE "
#include <QGlib/Connect>
int main()
{
QGlib::disconnect(0, 0, 0, 0);
QGlib::disconnect(NULL, NULL, NULL, NULL);
}
")
cxx_compilation_test(disconnect_default_args SHOULD_COMPILE "
#include <QGlib/Connect>
int main()
{
QGlib::disconnect(0, 0, 0);
QGlib::disconnect(0, 0);
QGlib::disconnect(0);
}
")
cxx_compilation_test(disconnect_non_member_slot SHOULD_FAIL "
#include <QGlib/Connect>
int foobar() {}
int main()
{
QGlib::disconnect(0, 0, 0, &foobar);
}
")
cxx_compilation_test(disconnect_string_slot SHOULD_FAIL "
#include <QGlib/Connect>
int main()
{
QGlib::disconnect(0, 0, 0, \"hello world\");
}
")
######### END disconnect tests ########
######### BEGIN bin add() tests ########
cxx_compilation_test(bin_add_test_1 SHOULD_COMPILE "
#include <QGst/Bin>
int main()
{
QGst::ElementPtr tee;
QGst::BinPtr bin;
bool b = bin->add(tee);
bin->add(tee, tee);
bin->add(tee, tee, tee);
bin->add(tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee, tee, tee, tee, tee);
bin->add(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
}
")
cxx_compilation_test(bin_add_test_2 SHOULD_COMPILE "
#define QGST_BIN_ADD_MAX_ARGS 12
#include <QGst/Bin>
int main()
{
QGst::ElementPtr tee;
QGst::BinPtr bin;
bin->add(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
}
")
######### END bin add() tests ########
######### BEGIN element linkMany/unlinkMany tests ########
cxx_compilation_test(element_linkMany_test_1 SHOULD_COMPILE "
#include <QGst/Element>
int main()
{
QGst::ElementPtr tee;
bool b = QGst::Element::linkMany(tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee);
b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
}
")
cxx_compilation_test(element_linkMany_test_2 SHOULD_COMPILE "
#define QGST_ELEMENT_LINK_MANY_MAX_ARGS 12
#define QGST_ELEMENT_UNLINK_MANY_MAX_ARGS 12
#include <QGst/Element>
int main()
{
QGst::ElementPtr tee;
bool b = QGst::Element::linkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
QGst::Element::unlinkMany(tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee, tee);
}
")
######### END element linkMany/unlinkMany tests ########
|