diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-03-17 10:53:08 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-03-17 10:53:08 (GMT) |
commit | 64ad0c327c365713e320f981d99cdd255912b4d7 (patch) | |
tree | a47cf76cd61a1e526b395de3248e01079ec3f21a /tests | |
parent | aaef4419fc4e9148354ae2d11a2ce2ef7af66313 (diff) | |
parent | ac704e9f682378a5ec56e3f5c195dcf2f2dfa1ac (diff) | |
download | Qt-64ad0c327c365713e320f981d99cdd255912b4d7.zip Qt-64ad0c327c365713e320f981d99cdd255912b4d7.tar.gz Qt-64ad0c327c365713e320f981d99cdd255912b4d7.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
PathView doesn't update if preferred highlight range changes.
Image.PreserveAspectFit has unexpected effect on Image's sourceSize
Doc improvement for Image.fillMode.
Diffstat (limited to 'tests')
4 files changed, 95 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml new file mode 100644 index 0000000..29fba40 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + + Item { + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: blueHandle.top + anchors.right: blueHandle.left + + Image { + id: iconImage + objectName: "iconImage" + anchors.top: parent.top + anchors.bottom: parent.bottom + source: "heart200.png" + fillMode: Image.PreserveAspectFit + smooth: true + } + } + + Rectangle { + id: blueHandle + objectName: "blueHandle" + color: "blue" + width: 25 + height: 25 + } +} diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f1fe2bd..9e090d2 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -89,6 +89,7 @@ private slots: void noLoading(); void paintedWidthHeight(); void sourceSize_QTBUG_14303(); + void sourceSize_QTBUG_16389(); void nullPixmapPaint(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); @@ -640,6 +641,29 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303() QTRY_COMPARE(sourceSizeSpy.count(), 2); } +void tst_qdeclarativeimage::sourceSize_QTBUG_16389() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml")); + canvas->show(); + qApp->processEvents(); + + QDeclarativeImage *image = findItem<QDeclarativeImage>(canvas->rootObject(), "iconImage"); + QDeclarativeItem *handle = findItem<QDeclarativeItem>(canvas->rootObject(), "blueHandle"); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 0.0); + QCOMPARE(image->paintedHeight(), 0.0); + + handle->setY(20); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 20.0); + QCOMPARE(image->paintedHeight(), 20.0); +} + static int numberOfWarnings = 0; static void checkWarnings(QtMsgType, const char *) { diff --git a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml index a361bdc..0f94840 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml @@ -9,7 +9,7 @@ PathView { startX: 0; startY: 100 PathLine { x: 400; y: 100 } } - delegate: Rectangle { height: 100; width: 1; color: PathView.isCurrentItem?"red" : "black" } + delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" } dragMargin: 100 preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index ebb5f98..8000137 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -111,6 +111,7 @@ private slots: void undefinedPath(); void mouseDrag(); void treeModel(); + void changePreferredHighlight(); private: QDeclarativeView *createView(); @@ -948,6 +949,45 @@ void tst_QDeclarativePathView::treeModel() delete canvas; } +void tst_QDeclarativePathView::changePreferredHighlight() +{ + QDeclarativeView *canvas = createView(); + canvas->setFixedSize(400,200); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml")); + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject()); + QVERIFY(pathview != 0); + + int current = pathview->currentIndex(); + QCOMPARE(current, 0); + + QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0); + QVERIFY(firstItem); + QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path()); + QVERIFY(path); + QPointF start = path->pointAt(0.5); + start.setX(qRound(start.x())); + start.setY(qRound(start.y())); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(firstItem->width()/2); + offset.setY(firstItem->height()/2); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->setPreferredHighlightBegin(0.8); + pathview->setPreferredHighlightEnd(0.8); + start = path->pointAt(0.8); + start.setX(qRound(start.x())); + start.setY(qRound(start.y())); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentIndex(), 0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); |