270 component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); |
270 component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); |
271 QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); |
271 QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); |
272 QVERIFY(obj != 0); |
272 QVERIFY(obj != 0); |
273 QCOMPARE(obj->pixmap().width(), 300); |
273 QCOMPARE(obj->pixmap().width(), 300); |
274 QCOMPARE(obj->pixmap().height(), 300); |
274 QCOMPARE(obj->pixmap().height(), 300); |
275 QCOMPARE(obj->width(), 550.0); |
275 QCOMPARE(obj->width(), 300.0); |
276 QCOMPARE(obj->height(), 500.0); |
276 QCOMPARE(obj->height(), 300.0); |
277 #if defined(Q_OS_MAC) |
277 #if defined(Q_OS_LINUX) |
278 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png")); |
278 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); |
279 #elif defined(Q_OS_WIN32) |
279 #elif defined(Q_OS_WIN32) |
280 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); |
280 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); |
281 #elif defined(QT_ARCH_ARM) |
|
282 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-arm.png")); |
|
283 #else |
|
284 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); |
|
285 #endif |
281 #endif |
286 |
282 |
287 obj->setSourceSize(QSize(200,200)); |
283 obj->setSourceSize(QSize(200,200)); |
288 |
284 |
289 QCOMPARE(obj->pixmap().width(), 200); |
285 QCOMPARE(obj->pixmap().width(), 200); |
290 QCOMPARE(obj->pixmap().height(), 200); |
286 QCOMPARE(obj->pixmap().height(), 200); |
291 QCOMPARE(obj->width(), 550.0); |
287 QCOMPARE(obj->width(), 200.0); |
292 QCOMPARE(obj->height(), 500.0); |
288 QCOMPARE(obj->height(), 200.0); |
293 #if defined(Q_OS_MAC) |
289 #if defined(Q_OS_LINUX) |
294 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png")); |
290 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); |
295 #elif defined(Q_OS_WIN32) |
291 #elif defined(Q_OS_WIN32) |
296 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); |
292 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); |
297 #elif defined(QT_ARCH_ARM) |
|
298 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-arm.png")); |
|
299 #else |
|
300 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); |
|
301 #endif |
293 #endif |
302 delete obj; |
294 delete obj; |
303 } |
295 } |
304 |
296 |
305 void tst_qdeclarativeimage::big() |
297 void tst_qdeclarativeimage::big() |
306 { |
298 { |
307 // If the JPEG loader does not implement scaling efficiently, it would |
299 // If the JPEG loader does not implement scaling efficiently, it would |
308 // have to build a 400 MB image. That would be a bug in the JPEG loader. |
300 // have to build a 400 MB image. That would be a bug in the JPEG loader. |
309 |
301 |
310 QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString(); |
302 QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString(); |
311 QString componentStr = "import Qt 4.7\nImage { source: \"" + src + "\"; sourceSize.width: 256; sourceSize.height: 256 }"; |
303 QString componentStr = "import Qt 4.7\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }"; |
312 |
304 |
313 QDeclarativeComponent component(&engine); |
305 QDeclarativeComponent component(&engine); |
314 component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); |
306 component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); |
315 QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); |
307 QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); |
316 QVERIFY(obj != 0); |
308 QVERIFY(obj != 0); |
317 QCOMPARE(obj->pixmap().width(), 256); |
309 QCOMPARE(obj->pixmap().width(), 256); |
318 QCOMPARE(obj->pixmap().height(), 256); |
310 QCOMPARE(obj->pixmap().height(), 256); |
319 QCOMPARE(obj->width(), 10240.0); |
311 QCOMPARE(obj->width(), 100.0); |
320 QCOMPARE(obj->height(), 10240.0); |
312 QCOMPARE(obj->height(), 256.0); |
321 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png")); |
313 QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png")); |
322 |
314 |
323 delete obj; |
315 delete obj; |
324 } |
316 } |
325 |
317 |