tests/auto/qpixmap/tst_qpixmap.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
--- a/tests/auto/qpixmap/tst_qpixmap.cpp	Fri Feb 19 23:40:16 2010 +0200
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp	Fri Mar 12 15:46:37 2010 +0200
@@ -145,9 +145,11 @@
     void fromWinHICON();
 #endif
 
-#if defined(Q_WS_S60)
+#if defined(Q_OS_SYMBIAN)
     void fromSymbianCFbsBitmap_data();
     void fromSymbianCFbsBitmap();
+    void toSymbianCFbsBitmap_data();
+    void toSymbianCFbsBitmap();
 #endif
 
     void onlyNullPixmapsOutsideGuiThread();
@@ -1110,7 +1112,7 @@
 
 #endif // Q_WS_WIN
 
-#if defined(Q_WS_S60)
+#if defined(Q_OS_SYMBIAN)
 Q_DECLARE_METATYPE(TDisplayMode)
 
 void tst_QPixmap::fromSymbianCFbsBitmap_data()
@@ -1206,6 +1208,45 @@
 
     CleanupStack::PopAndDestroy(3);
 }
+
+void tst_QPixmap::toSymbianCFbsBitmap_data()
+{
+    QTest::addColumn<int>("red");
+    QTest::addColumn<int>("green");
+    QTest::addColumn<int>("blue");
+
+    QTest::newRow("red")   << 255 << 0 << 0;
+    QTest::newRow("green") << 0 << 255 << 0;
+    QTest::newRow("blue")  << 0 << 0 << 255;
+}
+
+void tst_QPixmap::toSymbianCFbsBitmap()
+{
+    QFETCH(int, red);
+    QFETCH(int, green);
+    QFETCH(int, blue);
+
+    QPixmap pm(100, 100);
+    pm.fill(QColor(red, green, blue));
+
+    CFbsBitmap *bitmap = pm.toSymbianCFbsBitmap();
+
+    QVERIFY(bitmap != 0);
+
+    // Verify size
+    QCOMPARE(100, (int) bitmap->SizeInPixels().iWidth);
+    QCOMPARE(100, (int) bitmap->SizeInPixels().iHeight);
+
+    // Verify pixel color
+    TRgb pixel;
+    bitmap->GetPixel(pixel, TPoint(0,0));
+    QCOMPARE((int)pixel.Red(), red);
+    QCOMPARE((int)pixel.Green(), green);
+    QCOMPARE((int)pixel.Blue(), blue);
+
+    // Clean up
+    delete bitmap;
+}
 #endif
 
 void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()