tests/auto/qpixmap/tst_qpixmap.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
--- a/tests/auto/qpixmap/tst_qpixmap.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp	Fri Feb 19 23:40:16 2010 +0200
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -171,6 +171,8 @@
 
     void preserveDepth();
     void splash_crash();
+
+    void loadAsBitmapOrPixmap();
 };
 
 static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -1510,5 +1512,41 @@
     QCOMPARE(depth, source.depth());
 }
 
+void tst_QPixmap::loadAsBitmapOrPixmap()
+{
+    QImage tmp(10, 10, QImage::Format_RGB32);
+    tmp.save("tmp.png");
+
+    bool ok;
+
+    // Check that we can load the pixmap as a pixmap and that it then turns into a pixmap
+    QPixmap pixmap("tmp.png");
+    QVERIFY(!pixmap.isNull());
+    QVERIFY(pixmap.depth() > 1);
+    QVERIFY(!pixmap.isQBitmap());
+
+    pixmap = QPixmap();
+    ok = pixmap.load("tmp.png");
+    QVERIFY(ok);
+    QVERIFY(!pixmap.isNull());
+    QVERIFY(pixmap.depth() > 1);
+    QVERIFY(!pixmap.isQBitmap());
+
+    // The do the same check for bitmaps..
+    QBitmap bitmap("tmp.png");
+    QVERIFY(!bitmap.isNull());
+    QVERIFY(bitmap.depth() == 1);
+    QVERIFY(bitmap.isQBitmap());
+
+    bitmap = QBitmap();
+    ok = bitmap.load("tmp.png");
+    QVERIFY(ok);
+    QVERIFY(!bitmap.isNull());
+    QVERIFY(bitmap.depth() == 1);
+    QVERIFY(bitmap.isQBitmap());
+}
+
+
+
 QTEST_MAIN(tst_QPixmap)
 #include "tst_qpixmap.moc"