diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-05 15:41:16 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-05 15:41:16 (GMT) |
commit | caab2c851b4a1b67d57663d791e67f09c54b64fb (patch) | |
tree | deb8245ba69f326fb43e87a13b1b1e5378d90a8f /tests/auto/declarative/qdeclarativeimage | |
parent | 60b09b8915e2095b221eb0a16a76d49e5bb10391 (diff) | |
parent | d2c204a93f30238c705209e65e2e8bce148825cd (diff) | |
download | Qt-caab2c851b4a1b67d57663d791e67f09c54b64fb.zip Qt-caab2c851b4a1b67d57663d791e67f09c54b64fb.tar.gz Qt-caab2c851b4a1b67d57663d791e67f09c54b64fb.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: (24 commits)
Image bounding rect should always include the area being painted
Fix minehunt.pro (minehunt is no longer a plugin)
Don't allow flagging of flipped tiles in Minehunt
Remove Snake demo from QtDemo
Fix samegame text input focus
Whitespace fixes
Update visual tests for Mac.
Run all QML visual tests now.
Make qmlvisual tests more stable
Add documentation about script evaluation context and allowed types
Maintain passing visualtests on X11
Fix errors in example code. Also reverts the example code to the old
Largely rewrite the Using QML in C++ Applications documentation. It
Document list type operations
Fix regression in 648eb76c and update visual tests.
Don't emit xChanged()/yChanged() twice.
Add testcase for QTBUG-13719.
Doc fix
highlightranges.qml example and visual test contained binding loop.
Combining ListView.StrictlyEnforceRange and resizing currentItem stalls.
...
Diffstat (limited to 'tests/auto/declarative/qdeclarativeimage')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/data/rect.png | bin | 0 -> 171 bytes | |||
-rw-r--r-- | tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp | 74 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/data/rect.png b/tests/auto/declarative/qdeclarativeimage/data/rect.png Binary files differnew file mode 100644 index 0000000..d564a2d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/rect.png diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f1e026f..bf779ad 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -80,6 +80,8 @@ private slots: void preserveAspectRatio(); void smooth(); void svg(); + void geometry(); + void geometry_data(); void big(); void tiling_QTBUG_6716(); void noLoading(); @@ -288,6 +290,78 @@ void tst_qdeclarativeimage::svg() delete obj; } +void tst_qdeclarativeimage::geometry_data() +{ + QTest::addColumn<QString>("fillMode"); + QTest::addColumn<bool>("explicitWidth"); + QTest::addColumn<bool>("explicitHeight"); + QTest::addColumn<double>("itemWidth"); + QTest::addColumn<double>("paintedWidth"); + QTest::addColumn<double>("boundingWidth"); + QTest::addColumn<double>("itemHeight"); + QTest::addColumn<double>("paintedHeight"); + QTest::addColumn<double>("boundingHeight"); + + // tested image has width 200, height 100 + + // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match + QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0; + QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0; + + // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match + QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0; + QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; + QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; + + // bounding rect, painted rect and item rect are equal in stretching and tiling images + QStringList fillModes; + fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally"; + foreach (QString fillMode, fillModes) { + QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0; + QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0; + QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0; + } +} + +void tst_qdeclarativeimage::geometry() +{ + QFETCH(QString, fillMode); + QFETCH(bool, explicitWidth); + QFETCH(bool, explicitHeight); + QFETCH(double, itemWidth); + QFETCH(double, itemHeight); + QFETCH(double, paintedWidth); + QFETCH(double, paintedHeight); + QFETCH(double, boundingWidth); + QFETCH(double, boundingHeight); + + QString src = QUrl::fromLocalFile(SRCDIR "/data/rect.png").toString(); + QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; "; + + if (explicitWidth) + componentStr.append("width: 300; "); + if (explicitHeight) + componentStr.append("height: 400; "); + componentStr.append("}"); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->width(), itemWidth); + QCOMPARE(obj->paintedWidth(), paintedWidth); + QCOMPARE(obj->boundingRect().width(), boundingWidth); + + QCOMPARE(obj->height(), itemHeight); + QCOMPARE(obj->paintedHeight(), paintedHeight); + QCOMPARE(obj->boundingRect().height(), boundingHeight); + delete obj; +} + void tst_qdeclarativeimage::big() { // If the JPEG loader does not implement scaling efficiently, it would |