예제 #1
0
void SignalsTest::emitTypeTest()
{
    QGst::BinPtr bin = QGst::Bin::create("mybin");
    QGlib::connect(bin, "deep-notify", this, &SignalsTest::closureTestClosure, QGlib::PassSender);

    closureCalled = false;
    QGst::PipelinePtr pipeline = QGst::Pipeline::create("mypipeline");
    QGlib::emit<void>(bin, "deep-notify", pipeline, bin->findProperty("name"));
    QCOMPARE(closureCalled, true);
}
예제 #2
0
void SignalsTest::emitTest()
{
    QGst::BinPtr bin = QGst::Bin::create("mybin");
    bool isConnected = QGlib::connect(bin, "notify::name",
                                      this, &SignalsTest::emitTestClosure, QGlib::PassSender);

    QVERIFY(isConnected);

    closureCalled = false;
    QGlib::emit<void>(bin, "notify::name", bin->findProperty("name"));
    QCOMPARE(closureCalled, true);

    //calling with wrong return value. should show error message but *call* the signal
    //and return default constructed value for int
    closureCalled = false;
    int r = QGlib::emit<int>(bin, "notify::name", bin->findProperty("name"));
    QCOMPARE(r, int());
    QCOMPARE(closureCalled, true);

    //calling with wrong number of arguments. should show error message and *not call* the signal
    closureCalled = false;
    QGlib::emit<void>(bin, "notify::name");
    QCOMPARE(closureCalled, false);

    //calling wrong signal. will return default constructed value for int
    closureCalled = false;
    r = QGlib::emit<int>(bin, "foobar");
    QCOMPARE(r, int());
    QCOMPARE(closureCalled, false);

    isConnected = !QGlib::disconnect(bin, "notify::name", this, &SignalsTest::emitTestClosure);
    QVERIFY(!isConnected);

    closureCalled = false;
    QGlib::emit<void>(bin, "notify::name", bin->findProperty("name"));
    QCOMPARE(closureCalled, false);
}