From c194b012182c3ae495bb7a740f02a5a9f5b3c3b3 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 6 Jan 2012 14:02:10 +1000 Subject: [PATCH] Add tests for item polish bug on Mac On Mac OS X, if a QQuickItem triggers a polish request from Component.onCompleted, its updatePolish() function is not called. The tst_qquickitem::polishOnCompleted() test demonstrates this. If a running animation is added to the polishOnCompleted.qml in the test, the test will pass. Task-number: QTBUG-23481, QTBUG-23480, QTBUG-21590 Change-Id: I172b12e784aa458c43c23e0ee43f034f0bd332ee Reviewed-by: Martin Jones --- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 4 ++- .../qtquick2/qquickitem/data/polishOnCompleted.qml | 11 ++++++ tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp | 33 ++++++++++++++++++- .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 4 ++- .../qtquick2/qquickpathview/tst_qquickpathview.cpp | 8 ++-- 5 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 9232dc4..a83d8a2 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -3165,9 +3165,11 @@ void tst_QQuickGridView::resizeViewAndRepaint() QVERIFY(!findItem(contentItem, "wrapper", 10)); gridview->setHeight(320); + #ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23480", Abort); + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); #endif + QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); gridview->setHeight(100); diff --git a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml b/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml new file mode 100644 index 0000000..7008cdc --- /dev/null +++ b/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +TestPolishItem { + width: 200 + height: 200 + + Component.onCompleted: { + doPolish() + } +} diff --git a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp index e38dcf4..7e32816 100644 --- a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp @@ -73,9 +73,9 @@ class TestPolishItem : public QQuickItem { Q_OBJECT public: - TestPolishItem(QQuickItem *parent) + TestPolishItem(QQuickItem *parent = 0) : QQuickItem(parent), wasPolished(false) { - QTimer::singleShot(10, this, SLOT(doPolish())); + } bool wasPolished; @@ -109,6 +109,8 @@ class tst_qquickitem : public QDeclarativeDataTest public: private slots: + void initTestCase(); + void noCanvas(); void simpleFocus(); void scopedFocus(); @@ -123,6 +125,7 @@ private slots: void mouseGrab(); void polishOutsideAnimation(); + void polishOnCompleted(); void wheelEvent_data(); void wheelEvent(); @@ -146,6 +149,12 @@ private: } }; +void tst_qquickitem::initTestCase() +{ + QDeclarativeDataTest::initTestCase(); + qmlRegisterType("Qt.test", 1, 0, "TestPolishItem"); +} + // Focus has no effect when outside a canvas void tst_qquickitem::noCanvas() { @@ -862,12 +871,32 @@ void tst_qquickitem::polishOutsideAnimation() TestPolishItem *item = new TestPolishItem(canvas->rootItem()); item->setSize(QSizeF(200, 100)); QTest::qWait(50); + + QTimer::singleShot(10, item, SLOT(doPolish())); QTRY_VERIFY(item->wasPolished); delete item; delete canvas; } +void tst_qquickitem::polishOnCompleted() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("polishOnCompleted.qml")); + view->show(); + + TestPolishItem *item = qobject_cast(view->rootObject()); + QVERIFY(item); + +#ifdef Q_OS_MAC + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); +#endif + + QTRY_VERIFY(item->wasPolished); + + delete view; +} + void tst_qquickitem::wheelEvent_data() { QTest::addColumn("visible"); diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index bd96c6d..ccdc49e 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -3631,9 +3631,11 @@ void tst_QQuickListView::resizeViewAndRepaint() QVERIFY(!findItem(contentItem, "wrapper", 10)); listview->setHeight(320); + #ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23481", Abort); + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); #endif + QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); listview->setHeight(100); diff --git a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp index 68bff03..8c6dd19 100644 --- a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp @@ -1194,10 +1194,6 @@ void tst_QQuickPathView::pathUpdateOnStartChanged() void tst_QQuickPathView::package() { -#ifdef Q_OS_MAC - QSKIP("QTBUG-23482"); -#endif - QQuickView *canvas = createView(); QVERIFY(canvas); canvas->setSource(testFileUrl("pathview_package.qml")); @@ -1207,6 +1203,10 @@ void tst_QQuickPathView::package() QQuickPathView *pathView = canvas->rootObject()->findChild("photoPathView"); QVERIFY(pathView); +#ifdef Q_OS_MAC + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); +#endif + QQuickItem *item = findItem(pathView, "pathItem"); QVERIFY(item); QVERIFY(item->scale() != 1.0); -- 1.7.2.5