diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-04 10:37:11 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-04 10:37:11 (GMT) |
commit | 8bc0456491e5a7e1fc677fce6e76932ab0d923e8 (patch) | |
tree | 2e0634859448e83372cb9e381ac38e4bfbbe3a41 /tests/auto | |
parent | b3ccc9b30c3a176021b6205193b8baa416e9e813 (diff) | |
parent | 24c56ac5309150cf7ba42cd974df4e98d97ebb81 (diff) | |
download | Qt-8bc0456491e5a7e1fc677fce6e76932ab0d923e8.zip Qt-8bc0456491e5a7e1fc677fce6e76932ab0d923e8.tar.gz Qt-8bc0456491e5a7e1fc677fce6e76932ab0d923e8.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Build fix for Sun Studio
Finish to resolve merge conflict.
Fixes QMenu to only have static POD members
QScript: Test against QMetaType::QVariant instead of against the string
Fixes tst_QScriptExtQObject::connectAndDisconnect
Fix source compatibility of qRegisterMetaType
Fix warnings on MSVC
Updating documentation for how to build QWS with tslib
sizeHint of checkbox/radiobutton without text is not correct
Some cleanup of outdated src/3rdparty stuff
Revert "Fixes crash when destroying a QGraphicsItem."
Add config.test for multimedia/qml
Fix QVariant autotest
Fix compilation of Q_DECLARE_METATYPE(QVariant) by introducing QMetaType::QVariant
fixed a memory leak when restoring a state in QMainWindow
Make the sub-menu accessible via its shortcut even if it is the current
remove a warning on windows and simplify a bit the code
Add and use QGLContextPrivate::eglSurfaceForDevice()
QMetaType: Now we can register typedefs.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 57 | ||||
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 20 | ||||
-rw-r--r-- | tests/auto/qmetaobject/tst_qmetaobject.cpp | 20 | ||||
-rw-r--r-- | tests/auto/qmetatype/tst_qmetatype.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qobject/tst_qobject.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qvariant/tst_qvariant.cpp | 14 |
6 files changed, 79 insertions, 62 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 269ec24..7c1b97e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -438,7 +438,6 @@ private slots: void QTBUG_6738_missingUpdateWithSetParent(); void QTBUG_7714_fullUpdateDiscardingOpacityUpdate2(); void QT_2653_fullUpdateDiscardingOpacityUpdate(); - void QT_2649_focusScope(); private: QList<QGraphicsItem *> paintedItems; @@ -10003,61 +10002,5 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2() QTRY_COMPARE(view.repaints, 1); } -void tst_QGraphicsItem::QT_2649_focusScope() -{ - QGraphicsScene *scene = new QGraphicsScene; - - QGraphicsRectItem *subFocusItem = new QGraphicsRectItem; - subFocusItem->setFlags(QGraphicsItem::ItemIsFocusable); - subFocusItem->setFocus(); - QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem); - - QGraphicsRectItem *scope = new QGraphicsRectItem; - scope->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); - scope->setFocus(); - subFocusItem->setParentItem(scope); - QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0); - QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem); - - QGraphicsRectItem *rootItem = new QGraphicsRectItem; - rootItem->setFlags(QGraphicsItem::ItemIsFocusable); - scope->setParentItem(rootItem); - QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0); - QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0); - QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem); - - scene->addItem(rootItem); - - QEvent windowActivate(QEvent::WindowActivate); - qApp->sendEvent(scene, &windowActivate); - scene->setFocus(); - - QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0); - QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0); - QVERIFY(subFocusItem->hasFocus()); - - //If we hide the focusScope, the entire subFocus chain should be cleared - scope->hide(); - - QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)0); - QCOMPARE(scope->focusItem(), (QGraphicsItem *)0); - QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)0); - QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0); - QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem); - QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0); - QVERIFY(!subFocusItem->hasFocus()); - - delete scene; -} - QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 3559b15..e10d7ee 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -105,6 +105,7 @@ private slots: void deleteActionInTriggered(); void pushButtonPopulateOnAboutToShow(); void QTBUG7907_submenus_autoselect(); + void QTBUG7411_submenus_activate(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -948,6 +949,25 @@ void tst_QMenu::QTBUG7907_submenus_autoselect() QVERIFY(!subset.isVisible()); } +void tst_QMenu::QTBUG7411_submenus_activate() +{ + QMenu menu("Test Menu"); + QAction *act = menu.addAction("foo"); + QMenu sub1("&sub1"); + sub1.addAction("foo"); + sub1.setTitle("&sub1"); + QAction *act1 = menu.addMenu(&sub1); + menu.show(); + QTest::qWaitForWindowShown(&menu); + menu.setActiveAction(act); + QTest::keyPress(&menu, Qt::Key_Down); + QCOMPARE(menu.activeAction(), act1); + QVERIFY(!sub1.isVisible()); + QTest::keyPress(&menu, Qt::Key_S); + QTRY_VERIFY(sub1.isVisible()); +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index bd54975..bb4a0d2 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -157,6 +157,7 @@ private slots: void invokeQueuedMetaMember(); void invokeCustomTypes(); void invokeMetaConstructor(); + void invokeTypedefTypes(); void qtMetaObjectInheritance(); void normalizedSignature_data(); void normalizedSignature(); @@ -598,6 +599,8 @@ struct MyType int i1, i2, i3; }; +typedef QString CustomString; + class QtTestCustomObject: public QObject { Q_OBJECT @@ -607,6 +610,9 @@ public: public slots: void sl1(MyType myType); +signals: + void sig_custom(const CustomString &string); + public: int sum; }; @@ -664,6 +670,20 @@ void tst_QMetaObject::invokeMetaConstructor() } } +void tst_QMetaObject::invokeTypedefTypes() +{ + qRegisterMetaType<CustomString>("CustomString"); + QtTestCustomObject obj; + QSignalSpy spy(&obj, SIGNAL(sig_custom(CustomString))); + + QCOMPARE(spy.count(), 0); + CustomString arg("hello"); + QVERIFY(QMetaObject::invokeMethod(&obj, "sig_custom", Q_ARG(CustomString, arg))); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.at(0).at(0), QVariant(arg)); +} + void tst_QMetaObject::normalizedSignature_data() { QTest::addColumn<QString>("signature"); diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp index 943b05b..f4e122f 100644 --- a/tests/auto/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/qmetatype/tst_qmetatype.cpp @@ -241,6 +241,9 @@ void tst_QMetaType::construct() QMetaType::destroy(QMetaType::QSize, size); } +typedef QString CustomString; +Q_DECLARE_METATYPE(CustomString) //this line is useless + void tst_QMetaType::typedefs() { QCOMPARE(QMetaType::type("long long"), int(QMetaType::LongLong)); @@ -256,6 +259,13 @@ void tst_QMetaType::typedefs() // make sure the qreal typeId is the type id of the type it's defined to QCOMPARE(QMetaType::type("qreal"), ::qMetaTypeId<qreal>()); + + qRegisterMetaType<CustomString>("CustomString"); + QCOMPARE(QMetaType::type("CustomString"), ::qMetaTypeId<CustomString>()); + + typedef Whity<double> WhityDouble; + qRegisterMetaType<WhityDouble>("WhityDouble"); + QCOMPARE(QMetaType::type("WhityDouble"), ::qMetaTypeId<WhityDouble>()); } class IsRegisteredDummyType { }; @@ -286,9 +296,9 @@ void tst_QMetaType::isRegistered() QCOMPARE(QMetaType::isRegistered(typeId), registered); } -class RegUnreg +class RegUnreg { -public: +public: RegUnreg() {}; RegUnreg(const RegUnreg &) {}; ~RegUnreg() {}; diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 3896d70..c8f846e 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -1112,6 +1112,8 @@ void tst_QObject::streamCustomTypes() QCOMPARE(instanceCount, 0); } +typedef QString CustomString; + class PropertyObject : public QObject { Q_OBJECT @@ -1125,6 +1127,7 @@ class PropertyObject : public QObject Q_PROPERTY(CustomType* custom READ custom WRITE setCustom) Q_PROPERTY(float myFloat READ myFloat WRITE setMyFloat) Q_PROPERTY(qreal myQReal READ myQReal WRITE setMyQReal) + Q_PROPERTY(CustomString customString READ customString WRITE setCustomString ) public: enum Alpha { @@ -1163,6 +1166,9 @@ public: void setMyQReal(qreal value) { m_qreal = value; } qreal myQReal() const { return m_qreal; } + CustomString customString() const { return m_customString; } + void setCustomString(const QString &string) { m_customString = string; } + private: Alpha m_alpha; Priority m_priority; @@ -1172,6 +1178,7 @@ private: CustomType *m_custom; float m_float; qreal m_qreal; + CustomString m_customString; }; Q_DECLARE_METATYPE(PropertyObject::Priority) @@ -1626,6 +1633,15 @@ void tst_QObject::property() QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low); object.setProperty("priority", var); QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::High); + + qRegisterMetaType<CustomString>("CustomString"); + QVERIFY(mo->indexOfProperty("customString") != -1); + QCOMPARE(object.property("customString").toString(), QString()); + object.setCustomString("String1"); + QCOMPARE(object.property("customString"), QVariant("String1")); + QVERIFY(object.setProperty("customString", "String2")); + QCOMPARE(object.property("customString"), QVariant("String2")); + QVERIFY(!object.setProperty("customString", QVariant())); } void tst_QObject::metamethod() diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index a316dda..1a4182f 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2518,15 +2518,23 @@ void tst_QVariant::variant_to() QCOMPARE(qVariantFromValue(0.25f).toDouble(), 0.25); } +struct Blah { int i; }; + +QDataStream& operator>>(QDataStream& s, Blah& c) +{ return (s >> c.i); } + +QDataStream& operator<<(QDataStream& s, const Blah& c) +{ return (s << c.i); } + void tst_QVariant::saveLoadCustomTypes() { QByteArray data; - int i = 42; - int tp = qRegisterMetaType<int>("Blah"); + Blah i = { 42 }; + int tp = qRegisterMetaType<Blah>("Blah"); QVariant v = QVariant(tp, &i); - qRegisterMetaTypeStreamOperators<int>("Blah"); + qRegisterMetaTypeStreamOperators<Blah>("Blah"); QCOMPARE(v.userType(), tp); QVERIFY(v.type() == QVariant::UserType); |