diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-01-18 21:06:39 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-01-18 21:06:39 (GMT) |
commit | 11815c63abeaf2b768e0cf59a83b53ff2b160b05 (patch) | |
tree | 87b2d7bde7040db0aceb402a2d4486e014d8b08e /tests | |
parent | 8dc9f77250dfb11b2a7198b931e284e0f3d112e4 (diff) | |
parent | 44edbab6f4063565d74f8ebf9ccdacabed5ef5ba (diff) | |
download | Qt-11815c63abeaf2b768e0cf59a83b53ff2b160b05.zip Qt-11815c63abeaf2b768e0cf59a83b53ff2b160b05.tar.gz Qt-11815c63abeaf2b768e0cf59a83b53ff2b160b05.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-water-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-water-staging:
Revert "Add a warning about trying to release a timer ID that isn't active"
Some unit tests for layout explosion thingy
Fix a bug that got revealed by 604c51f1fc5c79b7fad12cda911b06b9e6e5005f
Build failure fix (related to QT-4079)
QWidgets support for VGA screen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 158 | ||||
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 26 |
2 files changed, 184 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 17cb7bf..891d0aa 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -120,6 +120,11 @@ private slots: void avoidRecursionInInsertItem(); void styleInfoLeak(); void task236367_maxSizeHint(); + void spanningItem2x2_data(); + void spanningItem2x2(); + void spanningItem2x3_data(); + void spanningItem2x3(); + void spanningItem(); void heightForWidth(); void heightForWidthWithSpanning(); void stretchAndHeightForWidth(); @@ -2860,6 +2865,159 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); } +Q_DECLARE_METATYPE(QSizePolicy::Policy) +void tst_QGraphicsGridLayout::spanningItem2x2_data() +{ + QTest::addColumn<QSizePolicy::Policy>("sizePolicy"); + QTest::addColumn<int>("itemHeight"); + QTest::addColumn<int>("expectedHeight"); + + QTest::newRow("A larger spanning item with 2 widgets with fixed policy") << QSizePolicy::Fixed << 39 << 80; + QTest::newRow("A larger spanning item with 2 widgets with preferred policy") << QSizePolicy::Preferred << 39 << 80; + QTest::newRow("An equally-sized spanning item with 2 widgets with fixed policy") << QSizePolicy::Fixed << 40 << 80; + QTest::newRow("An equally-sized spanning item with 2 widgets with preferred policy") << QSizePolicy::Preferred << 40 << 80; + QTest::newRow("A smaller spanning item with 2 widgets with fixed policy") << QSizePolicy::Fixed << 41 << 82; + QTest::newRow("A smaller spanning item with 2 widgets with preferred policy") << QSizePolicy::Preferred << 41 << 82; +} + +void tst_QGraphicsGridLayout::spanningItem2x2() +{ + QFETCH(QSizePolicy::Policy, sizePolicy); + QFETCH(int, itemHeight); + QFETCH(int, expectedHeight); + QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(form); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w1 = new QGraphicsWidget; + w1->setMinimumSize(80,80); + w1->setMaximumSize(80,80); + + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setMinimumSize(80,itemHeight); + w2->setPreferredSize(80,itemHeight); + w2->setSizePolicy(QSizePolicy::Fixed, sizePolicy); + + QGraphicsWidget *w3 = new QGraphicsWidget; + w3->setMinimumSize(80,itemHeight); + w3->setPreferredSize(80,itemHeight); + w3->setSizePolicy(QSizePolicy::Fixed, sizePolicy); + + layout->addItem(w1, 0, 0, 2, 1); + layout->addItem(w2, 0, 1); + layout->addItem(w3, 1, 1); + + QCOMPARE(layout->minimumSize(), QSizeF(160,expectedHeight)); + if(sizePolicy == QSizePolicy::Fixed) + QCOMPARE(layout->maximumSize(), QSizeF(160,expectedHeight)); + else + QCOMPARE(layout->maximumSize(), QSizeF(160,QWIDGETSIZE_MAX)); +} + +void tst_QGraphicsGridLayout::spanningItem2x3_data() +{ + QTest::addColumn<bool>("w1_fixed"); + QTest::addColumn<bool>("w2_fixed"); + QTest::addColumn<bool>("w3_fixed"); + QTest::addColumn<bool>("w4_fixed"); + QTest::addColumn<bool>("w5_fixed"); + + for(int w1 = 0; w1 < 2; w1++) + for(int w2 = 0; w2 < 2; w2++) + for(int w3 = 0; w3 < 2; w3++) + for(int w4 = 0; w4 < 2; w4++) + for(int w5 = 0; w5 < 2; w5++) { + QString description = QString("Fixed sizes:") + (w1?" w1":"") + (w2?" w2":"") + (w3?" w3":"") + (w4?" w4":"") + (w5?" w5":""); + QTest::newRow(description.toLatin1()) << (bool)w1 << (bool)w2 << (bool)w3 << (bool)w4 << (bool)w5; + } +} + +void tst_QGraphicsGridLayout::spanningItem2x3() +{ + QFETCH(bool, w1_fixed); + QFETCH(bool, w2_fixed); + QFETCH(bool, w3_fixed); + QFETCH(bool, w4_fixed); + QFETCH(bool, w5_fixed); + QGraphicsGridLayout *layout = new QGraphicsGridLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w1 = new QGraphicsWidget; + w1->setMinimumSize(80,80); + w1->setMaximumSize(80,80); + if (w1_fixed) + w1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setMinimumSize(80,48); + w2->setPreferredSize(80,48); + if (w2_fixed) + w2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + QGraphicsWidget *w3 = new QGraphicsWidget; + w3->setMinimumSize(80,30); + w3->setPreferredSize(80,30); + if (w3_fixed) + w3->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + QGraphicsWidget *w4 = new QGraphicsWidget; + w4->setMinimumSize(80,30); + w4->setMaximumSize(80,30); + if (w4_fixed) + w4->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + QGraphicsWidget *w5 = new QGraphicsWidget; + w5->setMinimumSize(40,24); + w5->setMaximumSize(40,24); + if (w5_fixed) + w5->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + + layout->addItem(w1, 0, 0, 2, 1); + layout->addItem(w2, 0, 1); + layout->addItem(w3, 1, 1); + layout->addItem(w4, 0, 2); + layout->addItem(w5, 1, 2); + + QCOMPARE(layout->minimumSize(), QSizeF(240,80)); + // Only w2 and w3 grow vertically, so when they have a fixed vertical size policy, + // the whole layout cannot grow vertically. + if (w2_fixed && w3_fixed) + QCOMPARE(layout->maximumSize(), QSizeF(QWIDGETSIZE_MAX,80)); + else + QCOMPARE(layout->maximumSize(), QSizeF(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX)); +} + +void tst_QGraphicsGridLayout::spanningItem() +{ + QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(form); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w1 = new QGraphicsWidget; + w1->setMinimumSize(80,80); + w1->setMaximumSize(80,80); + + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setMinimumSize(80,38); + w2->setPreferredSize(80,38); + w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + + QGraphicsWidget *w3 = new QGraphicsWidget; + w3->setMinimumSize(80,38); + w3->setPreferredSize(80,38); + w3->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + + layout->addItem(w1, 0, 0, 2, 1); + layout->addItem(w2, 0, 1); + layout->addItem(w3, 1, 1); + + QCOMPARE(layout->minimumSize(), QSizeF(160,80)); + QCOMPARE(layout->maximumSize(), QSizeF(160,80)); +} + void tst_QGraphicsGridLayout::stretchAndHeightForWidth() { QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index a024f65..62ba1b4 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -106,6 +106,7 @@ private slots: void testAlignmentInLargerLayout(); void testOffByOneInLargerLayout(); void testDefaultAlignment(); + void combineSizePolicies(); // Task specific tests void task218400_insertStretchCrash(); @@ -1583,6 +1584,31 @@ void tst_QGraphicsLinearLayout::testDefaultAlignment() QCOMPARE(w2->geometry(), QRectF(0,50,100,100)); } +void tst_QGraphicsLinearLayout::combineSizePolicies() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w1 = new QGraphicsWidget; + w1->setMaximumSize(200,200); + w1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + layout->addItem(w1); + + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setPreferredSize(50,50); + w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + layout->addItem(w2); + QCOMPARE(layout->maximumHeight(), qreal(200)); + + // now remove the fixed vertical size policy, and set instead the maximum height to 50 + // this should in effect give the same maximumHeight + w2->setMaximumHeight(50); + w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + QCOMPARE(layout->maximumHeight(), qreal(200)); +} + QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" |