summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2010-10-08 04:50:43 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2010-10-08 04:52:09 (GMT)
commite17a5398bf20b89834d4d6c7f4d9203f192b101f (patch)
tree270f6019ef3a99ee77738c9451db78b5d45138b6 /tests/auto/declarative
parentfd2d104988955e4e94252abd8d90507aa33dc10d (diff)
downloadQt-e17a5398bf20b89834d4d6c7f4d9203f192b101f.zip
Qt-e17a5398bf20b89834d4d6c7f4d9203f192b101f.tar.gz
Qt-e17a5398bf20b89834d4d6c7f4d9203f192b101f.tar.bz2
Image.sourceSize is incorrect after changing Image.source
Task-number: QTBUG-14303
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index 8f9b2ea..f1e026f 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -84,6 +84,7 @@ private slots:
void tiling_QTBUG_6716();
void noLoading();
void paintedWidthHeight();
+ void sourceSize_QTBUG_14303();
private:
template<typename T>
@@ -377,7 +378,7 @@ void tst_qdeclarativeimage::noLoading()
QTRY_COMPARE(statusSpy.count(), 0);
// Loading remote file
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png");
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/heart200.png");
QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading);
QTRY_VERIFY(obj->progress() == 0.0);
QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
@@ -388,7 +389,7 @@ void tst_qdeclarativeimage::noLoading()
// Loading remote file again - should not go through 'Loading' state.
ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png");
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/heart200.png");
QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
QTRY_VERIFY(obj->progress() == 1.0);
QTRY_COMPARE(sourceSpy.count(), 4);
@@ -436,6 +437,35 @@ void tst_qdeclarativeimage::paintedWidthHeight()
}
}
+void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
+{
+ QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+
+ QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready);
+
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 0);
+
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 120);
+ QTRY_COMPARE(obj->sourceSize().height(), 120);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
+
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 2);
+}
+
/*
Find an item with the specified objectName. If index is supplied then the
item must also evaluate the {index} expression equal to index