tests/auto/moc/tst_moc.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   487     void inlineSlotsWithThrowDeclaration();
   487     void inlineSlotsWithThrowDeclaration();
   488     void warnOnPropertyWithoutREAD();
   488     void warnOnPropertyWithoutREAD();
   489     void constructors();
   489     void constructors();
   490     void typenameWithUnsigned();
   490     void typenameWithUnsigned();
   491     void warnOnVirtualSignal();
   491     void warnOnVirtualSignal();
   492 
   492     void QTBUG5590_dummyProperty();
   493 signals:
   493 signals:
   494     void sigWithUnsignedArg(unsigned foo);
   494     void sigWithUnsignedArg(unsigned foo);
   495     void sigWithSignedArg(signed foo);
   495     void sigWithSignedArg(signed foo);
   496     void sigWithConstSignedArg(const signed foo);
   496     void sigWithConstSignedArg(const signed foo);
   497     void sigWithVolatileConstSignedArg(volatile const signed foo);
   497     void sigWithVolatileConstSignedArg(volatile const signed foo);
   815     QCOMPARE(QByteArray(o.metaObject()->className()), QByteArray("StructQObject"));
   815     QCOMPARE(QByteArray(o.metaObject()->className()), QByteArray("StructQObject"));
   816 }
   816 }
   817 
   817 
   818 #include "namespaced-flags.h"
   818 #include "namespaced-flags.h"
   819 
   819 
       
   820 Q_DECLARE_METATYPE(QList<Foo::Bar::Flags>);
       
   821 
   820 void tst_Moc::namespacedFlags()
   822 void tst_Moc::namespacedFlags()
   821 {
   823 {
   822     Foo::Baz baz;
   824     Foo::Baz baz;
   823     Foo::Bar bar;
   825     Foo::Bar bar;
   824 
   826 
   827 
   829 
   828     const QVariant v = bar.property("flags");
   830     const QVariant v = bar.property("flags");
   829     QVERIFY(v.isValid());
   831     QVERIFY(v.isValid());
   830     QVERIFY(baz.setProperty("flags", v));
   832     QVERIFY(baz.setProperty("flags", v));
   831     QVERIFY(baz.flags() == bar.flags());
   833     QVERIFY(baz.flags() == bar.flags());
       
   834 
       
   835     QList<Foo::Bar::Flags> l;
       
   836     l << baz.flags();
       
   837     QVariant v2 = baz.setProperty("flagsList", QVariant::fromValue(l));
       
   838     QCOMPARE(l, baz.flagsList());
       
   839     QCOMPARE(l, qvariant_cast<QList<Foo::Bar::Flags> >(baz.property("flagsList")));
   832 }
   840 }
   833 
   841 
   834 void tst_Moc::warnOnMultipleInheritance()
   842 void tst_Moc::warnOnMultipleInheritance()
   835 {
   843 {
   836 #ifdef MOC_CROSS_COMPILED
   844 #ifdef MOC_CROSS_COMPILED
  1207 #else
  1215 #else
  1208     QSKIP("Only tested on linux/gcc", SkipAll);
  1216     QSKIP("Only tested on linux/gcc", SkipAll);
  1209 #endif
  1217 #endif
  1210 }
  1218 }
  1211 
  1219 
       
  1220 
       
  1221 class QTBUG5590_DummyObject: public QObject
       
  1222 {
       
  1223     Q_OBJECT
       
  1224     Q_PROPERTY(bool dummy)
       
  1225 };
       
  1226 
       
  1227 class QTBUG5590_PropertyObject: public QTBUG5590_DummyObject
       
  1228 {
       
  1229     Q_OBJECT
       
  1230     Q_PROPERTY(int value READ value WRITE setValue)
       
  1231     Q_PROPERTY(int value2 READ value2 WRITE setValue2)
       
  1232 
       
  1233     public:
       
  1234         QTBUG5590_PropertyObject() :  m_value(85), m_value2(40) { }
       
  1235         int value() const { return m_value; }
       
  1236         void setValue(int value) { m_value = value; }
       
  1237         int value2() const { return m_value2; }
       
  1238         void setValue2(int value) { m_value2 = value; }
       
  1239     private:
       
  1240         int m_value, m_value2;
       
  1241 };
       
  1242 
       
  1243 void tst_Moc::QTBUG5590_dummyProperty()
       
  1244 {
       
  1245     QTBUG5590_PropertyObject o;
       
  1246     QCOMPARE(o.property("value").toInt(), 85);
       
  1247     QCOMPARE(o.property("value2").toInt(), 40);
       
  1248     o.setProperty("value", 32);
       
  1249     QCOMPARE(o.value(), 32);
       
  1250     o.setProperty("value2", 82);
       
  1251     QCOMPARE(o.value2(), 82);
       
  1252 }
       
  1253 
  1212 QTEST_APPLESS_MAIN(tst_Moc)
  1254 QTEST_APPLESS_MAIN(tst_Moc)
  1213 #include "tst_moc.moc"
  1255 #include "tst_moc.moc"
  1214 
  1256 
  1215 
  1257 
  1216 
  1258