155 void connectSlotsByName(); |
155 void connectSlotsByName(); |
156 void invokeMetaMember(); |
156 void invokeMetaMember(); |
157 void invokeQueuedMetaMember(); |
157 void invokeQueuedMetaMember(); |
158 void invokeCustomTypes(); |
158 void invokeCustomTypes(); |
159 void invokeMetaConstructor(); |
159 void invokeMetaConstructor(); |
|
160 void invokeTypedefTypes(); |
160 void qtMetaObjectInheritance(); |
161 void qtMetaObjectInheritance(); |
161 void normalizedSignature_data(); |
162 void normalizedSignature_data(); |
162 void normalizedSignature(); |
163 void normalizedSignature(); |
163 void normalizedType_data(); |
164 void normalizedType_data(); |
164 void normalizedType(); |
165 void normalizedType(); |
511 |
512 |
512 exp.clear(); |
513 exp.clear(); |
513 QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Q_RETURN_ARG(QString, exp), Q_ARG(QString, "hehe"))); |
514 QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Q_RETURN_ARG(QString, exp), Q_ARG(QString, "hehe"))); |
514 QCOMPARE(exp, QString("yessir")); |
515 QCOMPARE(exp, QString("yessir")); |
515 QCOMPARE(obj.slotResult, QString("sl1:hehe")); |
516 QCOMPARE(obj.slotResult, QString("sl1:hehe")); |
|
517 |
|
518 QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::doesNotExist()"); |
|
519 QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist")); |
|
520 QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)"); |
|
521 QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Q_ARG(QString, "arg"))); |
|
522 QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)"); |
|
523 QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Q_ARG(QString, "arg"))); |
|
524 QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)"); |
|
525 QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg"))); |
|
526 |
|
527 //should not have changed since last test. |
|
528 QCOMPARE(exp, QString("yessir")); |
|
529 QCOMPARE(obj.slotResult, QString("sl1:hehe")); |
516 } |
530 } |
517 |
531 |
518 void tst_QMetaObject::invokeQueuedMetaMember() |
532 void tst_QMetaObject::invokeQueuedMetaMember() |
519 { |
533 { |
520 QtTestObject obj; |
534 QtTestObject obj; |
649 QCOMPARE(obj2->parent(), (QObject*)&obj); |
668 QCOMPARE(obj2->parent(), (QObject*)&obj); |
650 QVERIFY(qobject_cast<NamespaceWithConstructibleClass::ConstructibleClass*>(obj2) != 0); |
669 QVERIFY(qobject_cast<NamespaceWithConstructibleClass::ConstructibleClass*>(obj2) != 0); |
651 } |
670 } |
652 } |
671 } |
653 |
672 |
|
673 void tst_QMetaObject::invokeTypedefTypes() |
|
674 { |
|
675 qRegisterMetaType<CustomString>("CustomString"); |
|
676 QtTestCustomObject obj; |
|
677 QSignalSpy spy(&obj, SIGNAL(sig_custom(CustomString))); |
|
678 |
|
679 QCOMPARE(spy.count(), 0); |
|
680 CustomString arg("hello"); |
|
681 QVERIFY(QMetaObject::invokeMethod(&obj, "sig_custom", Q_ARG(CustomString, arg))); |
|
682 QCOMPARE(spy.count(), 1); |
|
683 QCOMPARE(spy.at(0).count(), 1); |
|
684 QCOMPARE(spy.at(0).at(0), QVariant(arg)); |
|
685 } |
|
686 |
654 void tst_QMetaObject::normalizedSignature_data() |
687 void tst_QMetaObject::normalizedSignature_data() |
655 { |
688 { |
656 QTest::addColumn<QString>("signature"); |
689 QTest::addColumn<QString>("signature"); |
657 QTest::addColumn<QString>("result"); |
690 QTest::addColumn<QString>("result"); |
658 |
691 |
662 << "void foo(QMap<a,a>,QList<b>)"; |
695 << "void foo(QMap<a,a>,QList<b>)"; |
663 QTest::newRow("rettype") << "QList<int, int> foo()" << "QList<int,int>foo()"; |
696 QTest::newRow("rettype") << "QList<int, int> foo()" << "QList<int,int>foo()"; |
664 QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()"; |
697 QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()"; |
665 QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()"; |
698 QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()"; |
666 QTest::newRow("reference") << "QString &foo()" << "QString&foo()"; |
699 QTest::newRow("reference") << "QString &foo()" << "QString&foo()"; |
667 QTest::newRow("const2") << "void foo(QString const *)" << "void foo(const QString*)"; |
700 QTest::newRow("const1") << "void foo(QString const *)" << "void foo(const QString*)"; |
668 QTest::newRow("const2") << "void foo(QString * const)" << "void foo(QString*const)"; |
701 QTest::newRow("const2") << "void foo(QString * const)" << "void foo(QString*const)"; |
669 QTest::newRow("const3") << "void foo(QString const &)" << "void foo(QString)"; |
702 QTest::newRow("const3") << "void foo(QString const &)" << "void foo(QString)"; |
670 QTest::newRow("const4") << "void foo(const int)" << "void foo(int)"; |
703 QTest::newRow("const4") << "void foo(const int)" << "void foo(int)"; |
671 QTest::newRow("const5") << "void foo(const int, int const, const int &, int const &)" |
704 QTest::newRow("const5") << "void foo(const int, int const, const int &, int const &)" |
672 << "void foo(int,int,int,int)"; |
705 << "void foo(int,int,int,int)"; |
673 QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)"; |
706 QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)"; |
674 QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)"; |
707 QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)"; |
675 QTest::newRow("const7") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)"; |
708 QTest::newRow("const8") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)"; |
|
709 QTest::newRow("const9") << "void foo(const Foo<Bar>)" << "void foo(Foo<Bar>)"; |
|
710 QTest::newRow("const10") << "void foo(Foo<Bar>const)" << "void foo(Foo<Bar>)"; |
|
711 QTest::newRow("const11") << "void foo(Foo<Bar> *const)" << "void foo(Foo<Bar>*const)"; |
|
712 QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(Foo<Bar>*const*const)"; |
|
713 QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)"; |
|
714 QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)"; |
676 } |
715 } |
677 |
716 |
678 void tst_QMetaObject::normalizedSignature() |
717 void tst_QMetaObject::normalizedSignature() |
679 { |
718 { |
680 QFETCH(QString, signature); |
719 QFETCH(QString, signature); |
699 QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList< ::Foo::Bar>"; |
738 QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList< ::Foo::Bar>"; |
700 QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>"; |
739 QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>"; |
701 QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int> >"; |
740 QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int> >"; |
702 QTest::newRow("value1") << "const QString &" << "QString"; |
741 QTest::newRow("value1") << "const QString &" << "QString"; |
703 QTest::newRow("value2") << "QString const &" << "QString"; |
742 QTest::newRow("value2") << "QString const &" << "QString"; |
|
743 QTest::newRow("constInName1") << "constconst" << "constconst"; |
|
744 QTest::newRow("constInName2") << "constconst*" << "constconst*"; |
|
745 QTest::newRow("constInName3") << "const constconst&" << "constconst"; |
|
746 QTest::newRow("constInName4") << "constconst const*const" << "constconst*const"; |
|
747 QTest::newRow("class") << "const class foo&" << "foo"; |
|
748 QTest::newRow("struct") << "const struct foo*" << "const foo*"; |
|
749 QTest::newRow("struct2") << "struct foo const*" << "const foo*"; |
|
750 QTest::newRow("enum") << "enum foo" << "foo"; |
704 } |
751 } |
705 |
752 |
706 void tst_QMetaObject::normalizedType() |
753 void tst_QMetaObject::normalizedType() |
707 { |
754 { |
708 QFETCH(QString, type); |
755 QFETCH(QString, type); |