diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-24 17:18:05 +0200 |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-24 17:18:05 +0200 |
commit | 723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c (patch) | |
tree | f8e1c8693aceea8f1d2fc03d9ad1555b0a441a27 /tests | |
parent | f90d8f3fe7e39a20b93a2ddfe0704bc48f3bd5f9 (diff) | |
parent | dab9d7c67ed2eda150c8da9e41db75f7eeeecd0d (diff) | |
download | qt4-tools-723dfce0f2af6d93d2c1b50f5e44ad3cf63e058c.tar.gz |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
src/gui/kernel/qapplication_x11.cpp
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arthur/data/qps/clipping_state.qps | 15 | ||||
-rw-r--r-- | tests/arthur/data/qps/clipping_state_qps.png | bin | 5089 -> 5133 bytes | |||
-rw-r--r-- | tests/auto/qbytearray/tst_qbytearray.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 121 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 93 | ||||
-rw-r--r-- | tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro | 2 | ||||
-rw-r--r-- | tests/auto/qrect/tst_qrect.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qspinbox/tst_qspinbox.cpp | 44 | ||||
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 118 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qwizard/tst_qwizard.cpp | 22 | ||||
-rw-r--r-- | tests/auto/qxmlstream/tst_qxmlstream.cpp | 52 |
13 files changed, 350 insertions, 162 deletions
diff --git a/tests/arthur/data/qps/clipping_state.qps b/tests/arthur/data/qps/clipping_state.qps index fd9a80a558..3a661226a5 100644 --- a/tests/arthur/data/qps/clipping_state.qps +++ b/tests/arthur/data/qps/clipping_state.qps @@ -55,3 +55,18 @@ setClipping true setBrush #6300ff00 drawRect 25 25 50 50 + +# disable clipping followed by setClipRect +translate 150 0 + +setClipRect 0 0 50 50 ReplaceClip + +setClipping false + +setBrush #630000ff +drawRect 0 0 100 100 + +setClipRect 25 25 75 75 IntersectClip + +setBrush #6300ff00 +drawRect 25 25 50 50 diff --git a/tests/arthur/data/qps/clipping_state_qps.png b/tests/arthur/data/qps/clipping_state_qps.png Binary files differindex 9b3dee244a..28bee462c6 100644 --- a/tests/arthur/data/qps/clipping_state_qps.png +++ b/tests/arthur/data/qps/clipping_state_qps.png diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 0e3df5330e..78fbf32c7d 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -239,10 +239,6 @@ void tst_QByteArray::qUncompress() QTEST(::qUncompress(in), "out"); -#if defined Q_WS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4) - QSKIP("Corrupt data causes this test to lock up on Mac OS X Panther", SkipSingle); -#endif - QTEST(::qUncompress(in + "blah"), "out"); } #endif diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index ce4828a66e..a548329940 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -153,8 +153,11 @@ void tst_QGraphicsGridLayout::qgraphicsgridlayout() layout.columnStretchFactor(0); layout.count(); layout.horizontalSpacing(); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::itemAt: invalid row, column 0, 0"); layout.itemAt(0, 0); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::itemAt: invalid index 0"); layout.itemAt(0); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::removeAt: invalid index 0"); layout.removeAt(0); layout.rowAlignment(0); layout.rowCount(); @@ -191,7 +194,7 @@ class RectWidget : public QGraphicsWidget public: RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); @@ -235,11 +238,11 @@ static void populateLayout(QGraphicsGridLayout *gridLayout, int width, int heigh * |+---|---+|xxxx| * ||span=2 ||hole| * |+---|---+|xxxx| - * +----+----+----+ + * +----+----+----+ * |xxxx|+---|---+| * |hole||span=2 || * |xxxx|+---|---+| - * +----+----+----+ + * +----+----+----+ */ static void populateLayoutWithSpansAndHoles(QGraphicsGridLayout *gridLayout) { @@ -296,7 +299,7 @@ void tst_QGraphicsGridLayout::addItem() QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::addItem: invalid row/column: -1"); } else if (rowSpan < 1 || columnSpan < 1) { char buf[1024]; - ::qsnprintf(buf, sizeof(buf), "QGraphicsGridLayout::addItem: invalid row span/column span: %d", + ::qsnprintf(buf, sizeof(buf), "QGraphicsGridLayout::addItem: invalid row span/column span: %d", rowSpan < 1 ? rowSpan : columnSpan); QTest::ignoreMessage(QtWarningMsg, buf); } @@ -458,7 +461,7 @@ void tst_QGraphicsGridLayout::columnCount() QCOMPARE(layout->columnCount(), 3); layout->addItem(new RectWidget(widget), 1, 2); QCOMPARE(layout->columnCount(), 3); - + // ### Talk with Jasmin. Not sure if removeAt() should adjust columnCount(). widget->setLayout(0); layout = new QGraphicsGridLayout(); @@ -524,7 +527,7 @@ void tst_QGraphicsGridLayout::columnMinimumWidth() populateLayout(layout, 3, 2); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + // should at least be a very large number QCOMPARE(layout->columnMinimumWidth(0), 0.0); QCOMPARE(layout->columnMinimumWidth(0), layout->columnMinimumWidth(1)); @@ -559,7 +562,7 @@ void tst_QGraphicsGridLayout::columnPreferredWidth() populateLayout(layout, 3, 2); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + // default preferred width ?? QCOMPARE(layout->columnPreferredWidth(0), 0.0); QCOMPARE(layout->columnPreferredWidth(0), layout->columnPreferredWidth(1)); @@ -594,7 +597,7 @@ void tst_QGraphicsGridLayout::setColumnFixedWidth() populateLayout(layout, 3, 2); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + layout->setColumnFixedWidth(0, 20); layout->setColumnFixedWidth(2, 40); @@ -626,7 +629,7 @@ void tst_QGraphicsGridLayout::columnSpacing() layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); QCOMPARE(layout->columnSpacing(0), 0.0); - + layout->setColumnSpacing(0, 20); view.show(); widget->show(); @@ -655,7 +658,7 @@ void tst_QGraphicsGridLayout::columnStretchFactor() populateLayout(layout, 3, 2); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + layout->setColumnStretchFactor(0, 1); layout->setColumnStretchFactor(1, 2); layout->setColumnStretchFactor(2, 3); @@ -741,7 +744,7 @@ void tst_QGraphicsGridLayout::contentsMargins() scene.addItem(widget); widget->setLayout(layout); layout->addItem(sublayout,0, 1); - + qreal left, top, right, bottom; // sublayouts have 0 margin sublayout->getContentsMargins(&left, &top, &right, &bottom); @@ -750,7 +753,7 @@ void tst_QGraphicsGridLayout::contentsMargins() QCOMPARE(right, 0.0); QCOMPARE(bottom, 0.0); - // top level layouts have style dependent margins. + // top level layouts have style dependent margins. // we'll just check if its different from 0. (applies to all our styles) layout->getContentsMargins(&left, &top, &right, &bottom); QVERIFY(left >= 0.0); @@ -771,7 +774,7 @@ void tst_QGraphicsGridLayout::itemAt() scene.addItem(widget); widget->setLayout(layout); populateLayoutWithSpansAndHoles(layout); - + //itemAt(int row, int column) QVERIFY( layout->itemAt(0,0)); QVERIFY( layout->itemAt(0,1)); @@ -874,7 +877,7 @@ void tst_QGraphicsGridLayout::rowAlignment() QCOMPARE(layout->alignment(layout->itemAt(1,0)), Qt::AlignTop); QCOMPARE(layout->itemAt(1,0)->geometry(), QRectF(0, 101, 50, 50)); QCOMPARE(layout->rowAlignment(1), Qt::AlignVCenter); - QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(101, 126, 50, 50)); + QCOMPARE(layout->itemAt(1,1)->geometry(), QRectF(101, 126, 50, 50)); QCOMPARE(layout->alignment(layout->itemAt(2,0)), Qt::AlignHCenter); QCOMPARE(layout->itemAt(2,0)->geometry(), QRectF(25, 202, 50, 50)); QCOMPARE(layout->rowAlignment(2), Qt::AlignTop); @@ -922,7 +925,7 @@ void tst_QGraphicsGridLayout::rowMaximumHeight() populateLayout(layout, 2, 3); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + // should at least be a very large number QVERIFY(layout->rowMaximumHeight(0) >= 10000); QCOMPARE(layout->rowMaximumHeight(0), layout->rowMaximumHeight(1)); @@ -957,7 +960,7 @@ void tst_QGraphicsGridLayout::rowMinimumHeight() populateLayout(layout, 2, 3); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + // should at least be a very large number QCOMPARE(layout->rowMinimumHeight(0), 0.0); QCOMPARE(layout->rowMinimumHeight(0), layout->rowMinimumHeight(1)); @@ -992,7 +995,7 @@ void tst_QGraphicsGridLayout::rowPreferredHeight() populateLayout(layout, 2, 3); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + // default preferred height ?? QCOMPARE(layout->rowPreferredHeight(0), 0.0); QCOMPARE(layout->rowPreferredHeight(0), layout->rowPreferredHeight(1)); @@ -1028,7 +1031,7 @@ void tst_QGraphicsGridLayout::setRowFixedHeight() populateLayout(layout, 2, 3); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + layout->setRowFixedHeight(0, 20.); layout->setRowFixedHeight(2, 40.); @@ -1060,7 +1063,7 @@ void tst_QGraphicsGridLayout::rowSpacing() layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); QCOMPARE(layout->columnSpacing(0), 0.0); - + layout->setColumnSpacing(0, 20); view.show(); widget->show(); @@ -1090,7 +1093,7 @@ void tst_QGraphicsGridLayout::rowStretchFactor() populateLayout(layout, 2, 3); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - + layout->setRowStretchFactor(0, 1); layout->setRowStretchFactor(1, 2); layout->setRowStretchFactor(2, 3); @@ -1121,7 +1124,7 @@ void tst_QGraphicsGridLayout::setColumnSpacing() { QFETCH(int, column); QFETCH(qreal, spacing); - + QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -1175,7 +1178,7 @@ void tst_QGraphicsGridLayout::setRowSpacing() { QFETCH(int, row); QFETCH(qreal, spacing); - + QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -1229,7 +1232,7 @@ void tst_QGraphicsGridLayout::setSpacing() void tst_QGraphicsGridLayout::sizeHint_data() { - + /* QTest::addColumn<Qt::SizeHint>("which"); QTest::addColumn<QSizeF>("constraint"); @@ -1308,7 +1311,7 @@ void tst_QGraphicsGridLayout::layoutDirection() RectWidget *w4 = new RectWidget; w4->setMinimumSize(30, 20); layout->addItem(w4, 1, 1); - + layout->setAlignment(w2, Qt::AlignRight); layout->setAlignment(w3, Qt::AlignLeft); @@ -1325,7 +1328,7 @@ void tst_QGraphicsGridLayout::layoutDirection() QCOMPARE(w3->geometry().right(), 21.0); QCOMPARE(w4->geometry().left(), 37.0); QCOMPARE(w4->geometry().right(), 67.0); - + window->setLayoutDirection(Qt::RightToLeft); QApplication::processEvents(); QCOMPARE(w1->geometry().left(), 39.0); @@ -1336,7 +1339,7 @@ void tst_QGraphicsGridLayout::layoutDirection() QCOMPARE(w3->geometry().right(), 69.0); QCOMPARE(w4->geometry().left(), 3.0); QCOMPARE(w4->geometry().right(), 33.0); - + delete window; } @@ -1437,7 +1440,7 @@ struct ItemDesc m_sizes[Qt::MaximumSize] = sz; return (*this); } - + ItemDesc &alignment(Qt::Alignment alignment) { m_align = alignment; return (*this); @@ -1506,8 +1509,8 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); QTest::newRow("ignoreitem01") << (ItemList() @@ -1527,8 +1530,8 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); QTest::newRow("ignoreitem01_resize120x40") << (ItemList() @@ -1548,8 +1551,8 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF(120, 40) << (SizeList() - << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) - << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) + << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) + << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) ); QTest::newRow("ignoreitem11_resize120x40") << (ItemList() @@ -1569,8 +1572,8 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF(120, 60) << (SizeList() - << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) - << QSizeF(20,40) << QSizeF(40,40) << QSizeF(60,40) + << QSizeF(20,20) << QSizeF(40,20) << QSizeF(60,20) + << QSizeF(20,40) << QSizeF(40,40) << QSizeF(60,40) ); QTest::newRow("ignoreitem01_span01_resize70x60") << (ItemList() @@ -1589,10 +1592,10 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF(70, 60) << (SizeList() - << QSizeF(20,20) << QSizeF(10,60) << QSizeF(40,20) - << QSizeF(20,40) << QSizeF(40,40) + << QSizeF(20,20) << QSizeF(10,60) << QSizeF(40,20) + << QSizeF(20,40) << QSizeF(40,40) ); - + QTest::newRow("ignoreitem10_resize40x120") << (ItemList() << ItemDesc(0,0) .preferredSizeHint(QSizeF(10,10)) @@ -1610,11 +1613,11 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF(40, 120) << (SizeList() - << QSizeF(20,20) << QSizeF(20,20) - << QSizeF(20,40) << QSizeF(20,40) - << QSizeF(20,60) << QSizeF(20,60) + << QSizeF(20,20) << QSizeF(20,20) + << QSizeF(20,40) << QSizeF(20,40) + << QSizeF(20,60) << QSizeF(20,60) ); - + QTest::newRow("ignoreitem01_span02") << (ItemList() << ItemDesc(0,0) .preferredSizeHint(QSizeF(10,10)) @@ -1631,7 +1634,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(0,20) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(0,20) << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); @@ -1651,7 +1654,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(0,20) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(0,20) << QSizeF(10,10) << QSizeF(10,10) ); @@ -1670,7 +1673,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,20) << QSizeF(10,10) << QSizeF(0,20) + << QSizeF(10,20) << QSizeF(10,10) << QSizeF(0,20) << QSizeF(10,10) ); @@ -1690,7 +1693,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(20,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(20,10) << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); @@ -1710,10 +1713,10 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(20,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(20,10) << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); - + QTest::newRow("ignorecolumn1_resize70x60") << (ItemList() << ItemDesc(0,0) .preferredSizeHint(QSizeF(10,10)) @@ -1732,8 +1735,8 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF(70, 60) << (SizeList() - << QSizeF(20,20) << QSizeF(10,20) << QSizeF(40,20) - << QSizeF(20,40) << QSizeF(10,40) << QSizeF(40,40) + << QSizeF(20,20) << QSizeF(10,20) << QSizeF(40,20) + << QSizeF(20,40) << QSizeF(10,40) << QSizeF(40,40) ); QTest::newRow("ignorerow0") << (ItemList() @@ -1756,7 +1759,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() << QSizeF() << (SizeList() << QSizeF(10,0) << QSizeF(10,0) << QSizeF(10,0) - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) ); QTest::newRow("ignorerow1") << (ItemList() @@ -1778,10 +1781,10 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() ) << QSizeF() << (SizeList() - << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) + << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,0) << QSizeF(10,0) << QSizeF(10,0) ); - + QTest::newRow("ignorerow0_resize60x50") << (ItemList() << ItemDesc(0,0) .sizePolicy(QSizePolicy::Ignored) @@ -1802,9 +1805,9 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data() << QSizeF(60, 50) << (SizeList() << QSizeF(10,10) << QSizeF(20,10) << QSizeF(30,10) - << QSizeF(10,40) << QSizeF(20,40) << QSizeF(30,40) + << QSizeF(10,40) << QSizeF(20,40) << QSizeF(30,40) ); - + } void tst_QGraphicsGridLayout::defaultStretchFactors() @@ -1837,13 +1840,13 @@ void tst_QGraphicsGridLayout::defaultStretchFactors() view.resize(400,300); if (newSize.isValid()) widget->resize(newSize); - + QApplication::processEvents(); for (i = 0; i < expectedSizes.count(); ++i) { QSizeF itemSize = layout->itemAt(i)->geometry().size(); QCOMPARE(itemSize, expectedSizes.at(i)); } - + delete widget; } @@ -2024,7 +2027,7 @@ void tst_QGraphicsGridLayout::geometries_data() << (RectList() << QRectF(0, 0, 50,10) << QRectF(0, 10, 10,10) ); - + QTest::newRow("combine_min_sizes") << (ItemList() << ItemDesc(0,0) .minSize(QSizeF(50,10)) @@ -2035,7 +2038,7 @@ void tst_QGraphicsGridLayout::geometries_data() << (RectList() << QRectF(0, 0, 60,10) << QRectF(0, 10, 60,10) ); - + } void tst_QGraphicsGridLayout::geometries() diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 981efeb0d1..7552f18b46 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -173,6 +173,7 @@ private slots: void sceneBoundingRect(); void childrenBoundingRect(); void childrenBoundingRectTransformed(); + void childrenBoundingRect2(); void group(); void setGroup(); void nestedGroups(); @@ -2995,6 +2996,16 @@ void tst_QGraphicsItem::childrenBoundingRectTransformed() QCOMPARE(rect->childrenBoundingRect(), QRectF(-100, 75, 275, 250)); } +void tst_QGraphicsItem::childrenBoundingRect2() +{ + QGraphicsItemGroup box; + QGraphicsLineItem l1(0, 0, 100, 0, &box); + QGraphicsLineItem l2(100, 0, 100, 100, &box); + QGraphicsLineItem l3(0, 0, 0, 100, &box); + // Make sure lines (zero with/height) are included in the childrenBoundingRect. + QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100)); +} + void tst_QGraphicsItem::group() { QGraphicsScene scene; diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index b61b2bbed4..a30e5e5c7d 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -163,19 +163,19 @@ class RectWidget : public QGraphicsWidget public: RectWidget(QGraphicsItem *parent = 0, const QBrush &brush = QBrush()) : QGraphicsWidget(parent){ m_brush = brush;} - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->setBrush(m_brush); painter->drawRoundRect(rect()); } - + void setSizeHint(Qt::SizeHint which, const QSizeF &size) { m_sizeHints[which] = size; updateGeometry(); } - + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const { if (m_sizeHints[which].isValid()) { return m_sizeHints[which]; @@ -210,17 +210,16 @@ void tst_QGraphicsLinearLayout::qgraphicslinearlayout() layout.setOrientation(Qt::Vertical); layout.orientation(); QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::insertItem: cannot insert null item"); - //QCOMPARE(layout.count(), 0); + QCOMPARE(layout.count(), 0); layout.addItem(0); - //QCOMPARE(layout.count(), 0); + QCOMPARE(layout.count(), 0); layout.addStretch(0); - //QCOMPARE(layout.count(), 1); + QCOMPARE(layout.count(), 0); QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::insertItem: cannot insert null item"); layout.insertItem(0, 0); layout.insertStretch(0, 0); layout.removeItem(0); - layout.removeAt(0); - //QCOMPARE(layout.count(), 1); + QCOMPARE(layout.count(), 0); layout.setSpacing(0); layout.spacing(); QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::setStretchFactor: cannot assign a stretch factor to a null item"); @@ -231,8 +230,7 @@ void tst_QGraphicsLinearLayout::qgraphicslinearlayout() QCOMPARE(layout.alignment(0), 0); layout.setGeometry(QRectF()); layout.geometry(); - //QCOMPARE(layout.count(), 1); - layout.itemAt(0); + QCOMPARE(layout.count(), 0); layout.invalidate(); layout.sizeHint(Qt::MinimumSize, QSizeF()); } @@ -285,7 +283,7 @@ void tst_QGraphicsLinearLayout::alignment() int i; bool addWidget = true; for (i = 0; i < sizeof(alignmentsToTest)/sizeof(Qt::Alignment); ++i) { - QGraphicsLayoutItem *loutItem; + QGraphicsLayoutItem *loutItem; Qt::Alignment align = alignmentsToTest[i]; if (!align && i > 0) addWidget = false; @@ -537,7 +535,10 @@ void tst_QGraphicsLinearLayout::insertItem() QSizeF oldSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); layout.insertItem(insertItemAt, item); QCOMPARE(layout.count(), itemCount + layoutCount + 1); - QCOMPARE(layout.itemAt(insertItemAt), insertItemAt == -1 ? (QGraphicsLayoutItem*)0 : item); + + if (insertItemAt >= 0 && (itemCount + layoutCount >= 0)) { + QCOMPARE(layout.itemAt(itemCount + layoutCount), item); + } layout.activate(); QSizeF newSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); @@ -599,8 +600,7 @@ void tst_QGraphicsLinearLayout::insertStretch() } widget->setLayout(layout); layout->insertStretch(insertItemAt, stretch); - QCOMPARE(layout->itemAt(insertItemAt), (QGraphicsLayoutItem*)0); - QCOMPARE(layout->count(), itemCount + layoutCount + 1); + QCOMPARE(layout->count(), itemCount + layoutCount); layout->activate(); view.show(); @@ -669,7 +669,6 @@ void tst_QGraphicsLinearLayout::invalidate() void tst_QGraphicsLinearLayout::itemAt_data() { QTest::addColumn<int>("index"); - QTest::newRow("-1") << -1; QTest::newRow("0") << 0; QTest::newRow("1") << 1; QTest::newRow("2") << 2; @@ -681,7 +680,10 @@ void tst_QGraphicsLinearLayout::itemAt() // see also the insertItem() etc tests QFETCH(int, index); SubQGraphicsLinearLayout layout; - QCOMPARE(layout.itemAt(index), (QGraphicsLayoutItem*)0); + for (int i = 0; i < 3; ++i) + layout.addItem(new QGraphicsWidget); + + QVERIFY(layout.itemAt(index) != 0); } void tst_QGraphicsLinearLayout::orientation_data() @@ -695,7 +697,7 @@ void tst_QGraphicsLinearLayout::orientation_data() void tst_QGraphicsLinearLayout::orientation() { QFETCH(Qt::Orientation, orientation); - + QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -721,7 +723,7 @@ void tst_QGraphicsLinearLayout::orientation() qreal pos; if (initialOrientation == Qt::Horizontal) pos = item->pos().x(); - else + else pos = item->pos().y(); positions.append(pos); @@ -736,7 +738,7 @@ void tst_QGraphicsLinearLayout::orientation() QGraphicsWidget *item = static_cast<QGraphicsWidget*>(layout.itemAt(i)); if (initialOrientation == Qt::Horizontal) QCOMPARE(item->pos().y(), positions.at(i)); - else + else QCOMPARE(item->pos().x(), positions.at(i)); } @@ -779,19 +781,18 @@ void tst_QGraphicsLinearLayout::removeAt() layout.addItem(new SubQGraphicsLinearLayout); QSizeF oldSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); - QGraphicsLayoutItem *w = layout.itemAt(removeItemAt); - QGraphicsLayoutItem *wParent = 0; + QGraphicsLayoutItem *w = 0; + if (removeItemAt >= 0 && removeItemAt < layout.count()) + w = layout.itemAt(removeItemAt); if (w) { - wParent = w->parentLayoutItem(); + QGraphicsLayoutItem *wParent = w->parentLayoutItem(); QCOMPARE(wParent, static_cast<QGraphicsLayoutItem *>(&layout)); - } - layout.removeAt(removeItemAt); - if (w) { + layout.removeAt(removeItemAt); wParent = w->parentLayoutItem(); QCOMPARE(wParent, static_cast<QGraphicsLayoutItem *>(0)); + delete w; } - delete w; - QCOMPARE(layout.count(), itemCount + layoutCount - ((removeItemAt == -1) ? 0 : 1)); + QCOMPARE(layout.count(), itemCount + layoutCount - (w ? 1 : 0)); layout.activate(); QSizeF newSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); @@ -829,11 +830,15 @@ void tst_QGraphicsLinearLayout::removeItem() for (int i = 0; i < layoutCount; ++i) layout.addItem(new SubQGraphicsLinearLayout); - QGraphicsLayoutItem *w = layout.itemAt(removeItemAt); + QGraphicsLayoutItem *w = 0; + if (removeItemAt >= 0 && removeItemAt < layout.count()) + w = layout.itemAt(removeItemAt); QSizeF oldSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); - layout.removeItem(w); - delete w; - QCOMPARE(layout.count(), itemCount + layoutCount - ((removeItemAt == -1) ? 0 : 1)); + if (w) { + layout.removeItem(w); + delete w; + } + QCOMPARE(layout.count(), itemCount + layoutCount - (w ? 1 : 0)); layout.activate(); QSizeF newSizeHint = layout.sizeHint(Qt::PreferredSize, QSizeF()); @@ -882,7 +887,7 @@ void tst_QGraphicsLinearLayout::setSpacing_data() void tst_QGraphicsLinearLayout::setSpacing() { QFETCH(qreal, spacing); - + QGraphicsScene scene; QGraphicsView view(&scene); QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); @@ -994,7 +999,7 @@ void tst_QGraphicsLinearLayout::itemSpacing() /** * The stretch factors are not applied linearly, but they are used together with both the preferred size, maximum size to form the * internal effective stretch factor. - * There is only need to apply stretch factors if the size of the layout is different than the layouts preferred size. + * There is only need to apply stretch factors if the size of the layout is different than the layouts preferred size. * (If the size of the layout is the preferred size, then all items should get their preferred sizes. * However, imagine this use case: * Layout @@ -1007,7 +1012,7 @@ void tst_QGraphicsLinearLayout::itemSpacing() * layout->resize(120, h) * * In QLayout, C would become 50, B would become 50 and A would get 20. When scaling a layout this would give a jerky feeling, since - * the item with the highest stretch factor will first resize. When that has reached its maximum the next candidate for stretch will + * the item with the highest stretch factor will first resize. When that has reached its maximum the next candidate for stretch will * resize, and finally, item with the lowest stretch factor will resize. * In QGraphicsLinearLayout we try to scale all items so that they all reach their maximum at the same time. This means that * their relative sizes are not proportional to their stretch factors. @@ -1059,7 +1064,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor() view.show(); widget->show(); - + qreal firstStretch = -1; qreal firstExtent = -1.; qreal sumExtent = 0; @@ -1073,7 +1078,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor() QCOMPARE(extent, firstExtent); else if (stretch > firstStretch) QVERIFY(extent > firstExtent); - else + else QVERIFY(extent < firstExtent); } else { firstStretch = (qreal)stretch; @@ -1082,7 +1087,7 @@ void tst_QGraphicsLinearLayout::setStretchFactor() sumExtent+= extent; } QCOMPARE(sumExtent, totalSize); - + delete widget; } @@ -1167,7 +1172,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors() QSizePolicy sp = item->sizePolicy(); if (orientation == Qt::Horizontal) sp.setHorizontalPolicy(QSizePolicy::Policy(sp.horizontalPolicy() | QSizePolicy::IgnoreFlag)); - else + else sp.setVerticalPolicy(QSizePolicy::Policy(sp.verticalPolicy() | QSizePolicy::IgnoreFlag)); item->setSizePolicy(sp); } @@ -1180,7 +1185,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors() view.resize(400,300); if (newSize.isValid()) widget->resize(newSize); - + QApplication::processEvents(); for (i = 0; i < count; ++i) { QSizeF itemSize = layout->itemAt(i)->geometry().size(); @@ -1189,7 +1194,7 @@ void tst_QGraphicsLinearLayout::defaultStretchFactors() if (i < expectedSizes.count()) QCOMPARE(itemSize.width(), qreal(expectedSizes.at(i))); } - + delete widget; } @@ -1254,7 +1259,7 @@ void tst_QGraphicsLinearLayout::updateGeometry() layout->setContentsMargins(0, 0, 0, 0); QCOMPARE(w1->parentLayoutItem(), static_cast<QGraphicsLayoutItem*>(layout)); QCOMPARE(layout->parentLayoutItem(), static_cast<QGraphicsLayoutItem*>(window)); - + view.show(); QApplication::processEvents(); QCOMPARE(window->size().toSize(), QSize(100, 50)); @@ -1283,7 +1288,7 @@ void tst_QGraphicsLinearLayout::updateGeometry() QApplication::processEvents(); w1->setMinimumSize(120, 60); QApplication::processEvents(); - QCOMPARE(window->size().toSize(), QSize(124, 64)); + QCOMPARE(window->size().toSize(), QSize(124, 64)); } { @@ -1341,7 +1346,7 @@ void tst_QGraphicsLinearLayout::layoutDirection() w2->setPreferredSize(20, 20); w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); layout->addItem(w2); - + scene.addItem(window); window->setLayout(layout); view.show(); @@ -1359,7 +1364,7 @@ void tst_QGraphicsLinearLayout::layoutDirection() QCOMPARE(w1->geometry().left(), 29.0); QCOMPARE(w2->geometry().right(), 23.0); QCOMPARE(w2->geometry().left(), 3.0); - + delete window; } diff --git a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro index 07550559fb..2e41fcd9cd 100644 --- a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro @@ -1,5 +1,5 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkreply.cpp -INCLUDEPATH += $$(QTDIR)/src/3rdparty/zlib +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib QT = core network diff --git a/tests/auto/qrect/tst_qrect.cpp b/tests/auto/qrect/tst_qrect.cpp index cdb556015d..5a916363f5 100644 --- a/tests/auto/qrect/tst_qrect.cpp +++ b/tests/auto/qrect/tst_qrect.cpp @@ -4125,6 +4125,7 @@ void tst_QRect::unitedRect_data() QTest::newRow("test 13") << QRect() << QRect(10, 10, 10, 10) << QRect(10, 10, 10, 10); QTest::newRow("test 14") << QRect(10, 10, 10, 10) << QRect() << QRect(10, 10, 10, 10); QTest::newRow("test 15") << QRect() << QRect() << QRect(); + QTest::newRow("test 16") << QRect(0, 0, 100, 0) << QRect(0, 0, 0, 100) << QRect(0, 0, 100, 100); } void tst_QRect::unitedRect() @@ -4160,6 +4161,7 @@ void tst_QRect::unitedRectF_data() QTest::newRow("test 13") << QRectF() << QRectF(10, 10, 10, 10) << QRectF(10, 10, 10, 10); QTest::newRow("test 14") << QRectF(10, 10, 10, 10) << QRectF() << QRectF(10, 10, 10, 10); QTest::newRow("test 15") << QRectF() << QRectF() << QRectF(); + QTest::newRow("test 16") << QRectF(0, 0, 100, 0) << QRectF(0, 0, 0, 100) << QRectF(0, 0, 100, 100); } void tst_QRect::unitedRectF() diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index d161c85ebb..d6a208d3ce 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -65,6 +65,7 @@ #include <QDoubleSpinBox> #include <QVBoxLayout> #include <QKeySequence> +#include <QStackedWidget> #include <QDebug> #include "../../shared/util.h" @@ -142,6 +143,9 @@ private slots: void specialValue(); void textFromValue(); + + void sizeHint(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -956,5 +960,45 @@ void tst_QSpinBox::textFromValue() QCOMPARE(spinBox.textFromValue(INT_MIN), QString::number(INT_MIN)); } +class sizeHint_SpinBox : public QSpinBox +{ +public: + QSize sizeHint() const + { + ++sizeHintRequests; + return QSpinBox::sizeHint(); + } + mutable int sizeHintRequests; +}; + +void tst_QSpinBox::sizeHint() +{ + QWidget *widget = new QWidget; + QHBoxLayout *layout = new QHBoxLayout(widget); + sizeHint_SpinBox *spinBox = new sizeHint_SpinBox; + layout->addWidget(spinBox); + widget->show(); + QTest::qWait(100); + + // Prefix + spinBox->sizeHintRequests = 0; + spinBox->setPrefix(QLatin1String("abcdefghij")); + qApp->processEvents(); + QVERIFY(spinBox->sizeHintRequests > 0); + + // Suffix + spinBox->sizeHintRequests = 0; + spinBox->setSuffix(QLatin1String("abcdefghij")); + qApp->processEvents(); + QVERIFY(spinBox->sizeHintRequests > 0); + + // Range + spinBox->sizeHintRequests = 0; + spinBox->setRange(0, 1234567890); + spinBox->setValue(spinBox->maximum()); + qApp->processEvents(); + QVERIFY(spinBox->sizeHintRequests > 0); +} + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 553833c3f0..a859866a1d 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -151,6 +151,8 @@ private slots: void defaultGlobalRestorePolicy(); void globalRestorePolicySetToRestore(); void globalRestorePolicySetToDoNotRestore(); + + void noInitialStateForInitialState(); //void restorePolicyNotInherited(); //void mixedRestoreProperties(); @@ -345,7 +347,7 @@ void tst_QStateMachine::transitionEntersParent() void tst_QStateMachine::defaultErrorState() { QStateMachine machine; - QVERIFY(machine.errorState() != 0); + QCOMPARE(machine.errorState(), reinterpret_cast<QAbstractState *>(0)); QState *brokenState = new QState(); brokenState->setObjectName("MyInitialState"); @@ -364,9 +366,7 @@ void tst_QStateMachine::defaultErrorState() QCOMPARE(machine.error(), QStateMachine::NoInitialStateError); QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'MyInitialState'")); - - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(machine.errorState())); + QCOMPARE(machine.isRunning(), false); } class CustomErrorState: public QState @@ -424,6 +424,7 @@ void tst_QStateMachine::customGlobalErrorState() QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(customErrorState)); QCOMPARE(customErrorState->error, QStateMachine::NoInitialStateError); @@ -459,6 +460,7 @@ void tst_QStateMachine::customLocalErrorStateInBrokenState() machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1))); QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(customErrorState)); QCOMPARE(customErrorState->error, QStateMachine::NoInitialStateError); @@ -494,8 +496,7 @@ void tst_QStateMachine::customLocalErrorStateInOtherState() machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1))); QCoreApplication::processEvents(); - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(machine.errorState())); + QCOMPARE(machine.isRunning(), false); } void tst_QStateMachine::customLocalErrorStateInParentOfBrokenState() @@ -529,6 +530,7 @@ void tst_QStateMachine::customLocalErrorStateInParentOfBrokenState() machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1))); QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(customErrorState)); } @@ -607,6 +609,7 @@ void tst_QStateMachine::errorStateHasChildren() machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1))); QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 2); QVERIFY(machine.configuration().contains(customErrorState)); QVERIFY(machine.configuration().contains(childOfErrorState)); @@ -620,7 +623,6 @@ void tst_QStateMachine::errorStateHasErrors() customErrorState->setObjectName("customErrorState"); machine.addState(customErrorState); - QAbstractState *oldErrorState = machine.errorState(); machine.setErrorState(customErrorState); QState *childOfErrorState = new QState(customErrorState); @@ -647,8 +649,7 @@ void tst_QStateMachine::errorStateHasErrors() QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: Missing initial state in compound state 'customErrorState'"); QCoreApplication::processEvents(); - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(oldErrorState)); // Fall back to default + QCOMPARE(machine.isRunning(), false); QCOMPARE(machine.error(), QStateMachine::NoInitialStateError); QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'customErrorState'")); } @@ -680,8 +681,7 @@ void tst_QStateMachine::errorStateIsRootState() QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: Missing initial state in compound state 'brokenState'"); QCoreApplication::processEvents(); - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(machine.errorState())); + QCOMPARE(machine.isRunning(), false); } void tst_QStateMachine::errorStateEntersParentFirst() @@ -759,7 +759,6 @@ void tst_QStateMachine::errorStateEntersParentFirst() void tst_QStateMachine::customErrorStateIsNull() { QStateMachine machine; - QAbstractState *oldErrorState = machine.errorState(); machine.rootState()->setErrorState(0); QState *initialState = new QState(); @@ -780,8 +779,7 @@ void tst_QStateMachine::customErrorStateIsNull() QCoreApplication::processEvents(); QCOMPARE(machine.errorState(), reinterpret_cast<QAbstractState *>(0)); - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(oldErrorState)); + QCOMPARE(machine.isRunning(), false); } void tst_QStateMachine::clearError() @@ -797,6 +795,7 @@ void tst_QStateMachine::clearError() machine.start(); QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.error(), QStateMachine::NoInitialStateError); QCOMPARE(machine.errorString(), QString::fromLatin1("Missing initial state in compound state 'brokenState'")); @@ -862,6 +861,7 @@ void tst_QStateMachine::historyStateHasNowhereToGo() machine.postEvent(new QEvent(QEvent::User)); QCoreApplication::processEvents(); + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(machine.errorState())); QCOMPARE(machine.error(), QStateMachine::NoDefaultStateInHistoryStateError); @@ -920,8 +920,7 @@ void tst_QStateMachine::transitionToStateNotInGraph() QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 'initialState'"); QCoreApplication::processEvents(); - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(qobject_cast<QState*>(machine.rootState())->errorState())); + QCOMPARE(machine.isRunning(), false); } void tst_QStateMachine::customErrorStateNotInGraph() @@ -932,7 +931,7 @@ void tst_QStateMachine::customErrorStateNotInGraph() errorState.setObjectName("errorState"); QTest::ignoreMessage(QtWarningMsg, "QState::setErrorState: error state cannot belong to a different state machine"); machine.setErrorState(&errorState); - QVERIFY(&errorState != machine.errorState()); + QCOMPARE(machine.errorState(), reinterpret_cast<QAbstractState *>(0)); QState *initialBrokenState = new QState(machine.rootState()); initialBrokenState->setObjectName("initialBrokenState"); @@ -942,9 +941,8 @@ void tst_QStateMachine::customErrorStateNotInGraph() machine.start(); QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: Missing initial state in compound state 'initialBrokenState'"); QCoreApplication::processEvents(); - - QCOMPARE(machine.configuration().count(), 1); - QVERIFY(machine.configuration().contains(machine.errorState())); + + QCOMPARE(machine.isRunning(), false); } void tst_QStateMachine::restoreProperties() @@ -1019,8 +1017,7 @@ void tst_QStateMachine::addAndRemoveState() { QStateMachine machine; QStatePrivate *root_d = QStatePrivate::get(machine.rootState()); - QCOMPARE(root_d->childStates().size(), 1); // the error state - QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState()); + QCOMPARE(root_d->childStates().size(), 0); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: cannot add null state"); machine.addState(0); @@ -1031,9 +1028,8 @@ void tst_QStateMachine::addAndRemoveState() machine.addState(s1); QCOMPARE(s1->machine(), &machine); QCOMPARE(s1->parentState(), machine.rootState()); - QCOMPARE(root_d->childStates().size(), 2); - QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState()); - QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s1); + QCOMPARE(root_d->childStates().size(), 1); + QCOMPARE(root_d->childStates().at(0), (QAbstractState*)s1); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: state has already been added to this machine"); machine.addState(s1); @@ -1042,24 +1038,21 @@ void tst_QStateMachine::addAndRemoveState() QCOMPARE(s2->parentState(), (QState*)0); machine.addState(s2); QCOMPARE(s2->parentState(), machine.rootState()); - QCOMPARE(root_d->childStates().size(), 3); - QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState()); - QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s1); - QCOMPARE(root_d->childStates().at(2), (QAbstractState*)s2); + QCOMPARE(root_d->childStates().size(), 2); + QCOMPARE(root_d->childStates().at(0), (QAbstractState*)s1); + QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s2); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: state has already been added to this machine"); machine.addState(s2); machine.removeState(s1); QCOMPARE(s1->parentState(), (QState*)0); - QCOMPARE(root_d->childStates().size(), 2); - QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState()); - QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s2); + QCOMPARE(root_d->childStates().size(), 1); + QCOMPARE(root_d->childStates().at(0), (QAbstractState*)s2); machine.removeState(s2); QCOMPARE(s2->parentState(), (QState*)0); - QCOMPARE(root_d->childStates().size(), 1); - QCOMPARE(root_d->childStates().at(0), (QAbstractState*)machine.errorState()); + QCOMPARE(root_d->childStates().size(), 0); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::removeState: cannot remove null state"); machine.removeState(0); @@ -1067,10 +1060,10 @@ void tst_QStateMachine::addAndRemoveState() { QStateMachine machine2; { - char warning[256]; - sprintf(warning, "QStateMachine::removeState: state %p's machine (%p) is different from this machine (%p)", - machine2.rootState(), &machine2, &machine); - QTest::ignoreMessage(QtWarningMsg, warning); + QString warning; + warning.sprintf("QStateMachine::removeState: state %p's machine (%p) is different from this machine (%p)", + machine2.rootState(), &machine2, &machine); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); machine.removeState(machine2.rootState()); } // ### check this behavior @@ -1129,9 +1122,9 @@ void tst_QStateMachine::stateEntryAndExit() QCOMPARE(trans->sourceState(), (QState*)s2); QCOMPARE(trans->targetState(), (QAbstractState*)s3); { - char warning[256]; - sprintf(warning, "QState::removeTransition: transition %p's source state (%p) is different from this state (%p)", trans, s2, s1); - QTest::ignoreMessage(QtWarningMsg, warning); + QString warning; + warning.sprintf("QState::removeTransition: transition %p's source state (%p) is different from this state (%p)", trans, s2, s1); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); s1->removeTransition(trans); } s2->removeTransition(trans); @@ -1147,9 +1140,9 @@ void tst_QStateMachine::stateEntryAndExit() machine.setInitialState(s1); QCOMPARE(machine.initialState(), (QAbstractState*)s1); { - char warning[256]; - sprintf(warning, "QState::setInitialState: state %p is not a child of this state (%p)", machine.rootState(), machine.rootState()); - QTest::ignoreMessage(QtWarningMsg, warning); + QString warning; + warning.sprintf("QState::setInitialState: state %p is not a child of this state (%p)", machine.rootState(), machine.rootState()); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); machine.setInitialState(machine.rootState()); QCOMPARE(machine.initialState(), (QAbstractState*)s1); } @@ -1614,9 +1607,9 @@ void tst_QStateMachine::parallelStates() s1_2_1->addTransition(s1_2_f); s1_2->setInitialState(s1_2_1); { - char warning[256]; - sprintf(warning, "QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", s1); - QTest::ignoreMessage(QtWarningMsg, warning); + QString warning; + warning.sprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", s1); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); s1->setInitialState(0); } machine.addState(s1); @@ -2286,9 +2279,9 @@ void tst_QStateMachine::historyStates() QCOMPARE(s0h->defaultState(), (QAbstractState*)0); s0h->setDefaultState(s00); QCOMPARE(s0h->defaultState(), (QAbstractState*)s00); - char warning[256]; - sprintf(warning, "QHistoryState::setDefaultState: state %p does not belong to this history state's group (%p)", s0, s0); - QTest::ignoreMessage(QtWarningMsg, warning); + QString warning; + warning.sprintf("QHistoryState::setDefaultState: state %p does not belong to this history state's group (%p)", s0, s0); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); s0h->setDefaultState(s0); QState *s1 = new QState(root); QFinalState *s2 = new QFinalState(root); @@ -2393,12 +2386,10 @@ void tst_QStateMachine::targetStateWithNoParent() QSignalSpy finishedSpy(&machine, SIGNAL(finished())); machine.start(); QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); - QTRY_COMPARE(machine.isRunning(), true); QTRY_COMPARE(startedSpy.count(), 1); - QCOMPARE(stoppedSpy.count(), 0); + QCOMPARE(machine.isRunning(), false); + QCOMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(machine.configuration().size(), 1); - QVERIFY(machine.configuration().contains(machine.errorState())); QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); } @@ -2453,6 +2444,25 @@ void tst_QStateMachine::defaultGlobalRestorePolicy() QCOMPARE(propertyHolder->property("b").toInt(), 4); } +void tst_QStateMachine::noInitialStateForInitialState() +{ + QStateMachine machine; + + QState *initialState = new QState(machine.rootState()); + initialState->setObjectName("initialState"); + machine.setInitialState(initialState); + + QState *childState = new QState(initialState); + + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: " + "Missing initial state in compound state 'initialState'"); + machine.start(); + QCoreApplication::processEvents(); + + QCOMPARE(machine.isRunning(), false); + QCOMPARE(int(machine.error()), int(QStateMachine::NoInitialStateError)); +} + /* void tst_QStateMachine::restorePolicyNotInherited() { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 6727b0526c..dd9a3e052d 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -252,6 +252,7 @@ private slots: void moveChild_data(); void moveChild(); + void showAndMoveChild(); void subtractOpaqueSiblings(); @@ -5318,6 +5319,33 @@ void tst_QWidget::moveChild() parent.color); } +void tst_QWidget::showAndMoveChild() +{ + QWidget parent(0, Qt::FramelessWindowHint); + parent.resize(300, 300); + parent.setPalette(Qt::red); + parent.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&parent); +#endif + QTest::qWait(200); + + const QPoint tlwOffset = parent.geometry().topLeft(); + QWidget child(&parent); + child.resize(100, 100); + child.setPalette(Qt::blue); + child.setAutoFillBackground(true); + + // Ensure that the child is repainted correctly when moved right after show. + // NB! Do NOT processEvents() (or qWait()) in between show() and move(). + child.show(); + child.move(150, 150); + qApp->processEvents(); + + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); +} + void tst_QWidget::subtractOpaqueSiblings() { #ifdef QT_MAC_USE_COCOA diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp index 71e1c3e5c8..e5074b3c01 100644 --- a/tests/auto/qwizard/tst_qwizard.cpp +++ b/tests/auto/qwizard/tst_qwizard.cpp @@ -112,6 +112,7 @@ private slots: void task161658_alignments(); void task177022_setFixedSize(); void task248107_backButton(); + void task255350_fieldObjectDestroyed(); /* Things that could be added: @@ -2517,5 +2518,26 @@ void tst_QWizard::task248107_backButton() QCOMPARE(wizard.currentPage(), &page1); } +class WizardPage_task255350 : public QWizardPage +{ +public: + QLineEdit *lineEdit; + WizardPage_task255350() + : lineEdit(new QLineEdit) + { + registerField("dummy*", lineEdit); + } +}; + +void tst_QWizard::task255350_fieldObjectDestroyed() +{ + QWizard wizard; + WizardPage_task255350 *page = new WizardPage_task255350; + int id = wizard.addPage(page); + delete page->lineEdit; + wizard.removePage(id); // don't crash! + delete page; +} + QTEST_MAIN(tst_QWizard) #include "tst_qwizard.moc" diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index 32fdb91d17..153391324b 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -561,6 +561,8 @@ private slots: void garbageInXMLPrologDefaultCodec() const; void garbageInXMLPrologUTF8Explicitly() const; void clear() const; + void checkCommentIndentation() const; + void checkCommentIndentation_data() const; private: static QByteArray readFile(const QString &filename); @@ -1392,5 +1394,55 @@ void tst_QXmlStream::clear() const // task 228768 QCOMPARE(reader.tokenType(), QXmlStreamReader::EndDocument); } +void tst_QXmlStream::checkCommentIndentation_data() const +{ + + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("expectedOutput"); + + QString simpleInput = "<a><!-- bla --></a>"; + QString simpleOutput = "<?xml version=\"1.0\"?>\n" + "<a>\n" + " <!-- bla -->\n" + "</a>\n"; + QTest::newRow("simple-comment") << simpleInput << simpleOutput; + + QString advancedInput = "<a><!-- bla --><!-- bla --><b><!-- bla --><c><!-- bla --></c><!-- bla --></b></a>"; + QString advancedOutput = "<?xml version=\"1.0\"?>\n" + "<a>\n" + " <!-- bla -->\n" + " <!-- bla -->\n" + " <b>\n" + " <!-- bla -->\n" + " <c>\n" + " <!-- bla -->\n" + " </c>\n" + " <!-- bla -->\n" + " </b>\n" + "</a>\n"; + QTest::newRow("advanced-comment") << advancedInput << advancedOutput; +} + +void tst_QXmlStream::checkCommentIndentation() const // task 256468 +{ + QFETCH(QString, input); + QFETCH(QString, expectedOutput); + QString output; + QXmlStreamReader reader(input); + QXmlStreamWriter writer(&output); + writer.setAutoFormatting(true); + writer.setAutoFormattingIndent(3); + + while (!reader.atEnd()) { + reader.readNext(); + if (reader.error()) { + QFAIL("error reading XML input"); + } else { + writer.writeCurrentToken(reader); + } + } + QCOMPARE(output, expectedOutput); +} + #include "tst_qxmlstream.moc" // vim: et:ts=4:sw=4:sts=4 |