tests/auto/qpixmap/tst_qpixmap.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
   169     void fromData();
   169     void fromData();
   170     void loadFromDataNullValues();
   170     void loadFromDataNullValues();
   171 
   171 
   172     void preserveDepth();
   172     void preserveDepth();
   173     void splash_crash();
   173     void splash_crash();
       
   174 
       
   175     void loadAsBitmapOrPixmap();
   174 };
   176 };
   175 
   177 
   176 static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
   178 static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
   177 {
   179 {
   178     QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32);
   180     QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32);
  1508     painter.end();
  1510     painter.end();
  1509 
  1511 
  1510     QCOMPARE(depth, source.depth());
  1512     QCOMPARE(depth, source.depth());
  1511 }
  1513 }
  1512 
  1514 
       
  1515 void tst_QPixmap::loadAsBitmapOrPixmap()
       
  1516 {
       
  1517     QImage tmp(10, 10, QImage::Format_RGB32);
       
  1518     tmp.save("tmp.png");
       
  1519 
       
  1520     bool ok;
       
  1521 
       
  1522     // Check that we can load the pixmap as a pixmap and that it then turns into a pixmap
       
  1523     QPixmap pixmap("tmp.png");
       
  1524     QVERIFY(!pixmap.isNull());
       
  1525     QVERIFY(pixmap.depth() > 1);
       
  1526     QVERIFY(!pixmap.isQBitmap());
       
  1527 
       
  1528     pixmap = QPixmap();
       
  1529     ok = pixmap.load("tmp.png");
       
  1530     QVERIFY(ok);
       
  1531     QVERIFY(!pixmap.isNull());
       
  1532     QVERIFY(pixmap.depth() > 1);
       
  1533     QVERIFY(!pixmap.isQBitmap());
       
  1534 
       
  1535     // The do the same check for bitmaps..
       
  1536     QBitmap bitmap("tmp.png");
       
  1537     QVERIFY(!bitmap.isNull());
       
  1538     QVERIFY(bitmap.depth() == 1);
       
  1539     QVERIFY(bitmap.isQBitmap());
       
  1540 
       
  1541     bitmap = QBitmap();
       
  1542     ok = bitmap.load("tmp.png");
       
  1543     QVERIFY(ok);
       
  1544     QVERIFY(!bitmap.isNull());
       
  1545     QVERIFY(bitmap.depth() == 1);
       
  1546     QVERIFY(bitmap.isQBitmap());
       
  1547 }
       
  1548 
       
  1549 
       
  1550 
  1513 QTEST_MAIN(tst_QPixmap)
  1551 QTEST_MAIN(tst_QPixmap)
  1514 #include "tst_qpixmap.moc"
  1552 #include "tst_qpixmap.moc"