summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-06-05 09:51:06 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-06-05 09:51:06 (GMT)
commit09a0ccc875964cee802da0a18d20373dca240ed2 (patch)
tree397aaff763a80f823a00b5c3fd109aad38cf08aa /tests
parentbb077716c34993117eb96a806321a970fa56387d (diff)
parented0156a4269cd5c4ee13368b8c366bb7af2f489f (diff)
downloadQt-09a0ccc875964cee802da0a18d20373dca240ed2.zip
Qt-09a0ccc875964cee802da0a18d20373dca240ed2.tar.gz
Qt-09a0ccc875964cee802da0a18d20373dca240ed2.tar.bz2
Merge branch 'master' of git@scm.dev.troll.no:qt/qt-s60-public
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qpixmap/qpixmap.pro19
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp101
2 files changed, 108 insertions, 12 deletions
diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro
index aa767aa..c992f6e 100644
--- a/tests/auto/qpixmap/qpixmap.pro
+++ b/tests/auto/qpixmap/qpixmap.pro
@@ -1,26 +1,21 @@
load(qttest_p4)
SOURCES += tst_qpixmap.cpp
contains(QT_CONFIG, qt3support): QT += qt3support
-wince*: {
+wince*|symbian*: {
task31722_0.sources = convertFromImage/task31722_0/*
task31722_0.path = convertFromImage/task31722_0
task31722_1.sources = convertFromImage/task31722_1/*
task31722_1.path = convertFromImage/task31722_1
DEPLOYMENT += task31722_0 task31722_1
- DEFINES += SRCDIR=\\\".\\\"
}
-symbian*:{
- task31722_0.sources = convertFromImage/task31722_0/*
- task31722_0.path = convertFromImage/task31722_0
- task31722_1.sources = convertFromImage/task31722_1/*
- task31722_1.path = convertFromImage/task31722_1
- DEPLOYMENT += task31722_0 task31722_1
+
+wince*: {
+ DEFINES += SRCDIR=\\\".\\\"
+} symbian*: {
DEPLOYMENT_PLUGIN += qmng
-}
-else {
+ LIBS += -lfbscli.lib -lbitgdi.lib -lgdi.lib
+} else {
DEFINES += SRCDIR=\\\"$$PWD\\\"
win32:LIBS += -lgdi32 -luser32
}
-
-
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 493333b..9f73e34 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -58,6 +58,14 @@
#include <qscreen_qws.h>
#endif
+#ifdef Q_OS_SYMBIAN
+#include <e32std.h>
+#include <fbs.h>
+#include <gdi.h>
+#include <bitdev.h>
+#endif
+
+
//TESTED_CLASS=
//TESTED_FILES=
#if defined(Q_OS_SYMBIAN)
@@ -120,6 +128,11 @@ private slots:
void fromWinHBITMAP();
#endif
+#if defined(Q_WS_S60)
+ void fromSymbianCFbsBitmap_data();
+ void fromSymbianCFbsBitmap();
+#endif
+
void onlyNullPixmapsOutsideGuiThread();
void refUnref();
@@ -798,6 +811,94 @@ void tst_QPixmap::fromWinHBITMAP()
#endif
+#if defined(Q_WS_S60)
+Q_DECLARE_METATYPE(TDisplayMode)
+
+void tst_QPixmap::fromSymbianCFbsBitmap_data()
+{
+ QTest::addColumn<TDisplayMode>("format");
+ QTest::addColumn<int>("width");
+ QTest::addColumn<int>("height");
+ QTest::addColumn<QColor>("color");
+
+ const int smallWidth = 20;
+ const int smallHeight = 20;
+ const int largeWidth = 240;
+ const int largeHeight = 320;
+
+ // Indexed Color Formats - Disabled since images seem to be blank -> no palette?
+// QTest::newRow("EGray2 small") << EGray2 << smallWidth << smallHeight << QColor(Qt::black);
+// QTest::newRow("EGray2 big") << EGray2 << largeWidth << largeHeight << QColor(Qt::black);
+// QTest::newRow("EGray256 small") << EGray256 << smallWidth << smallHeight << QColor(Qt::blue);
+// QTest::newRow("EGray256 big") << EGray256 << largeWidth << largeHeight << QColor(Qt::blue);
+// QTest::newRow("EColor256 small") << EColor256 << smallWidth << smallHeight << QColor(Qt::red);
+// QTest::newRow("EColor256 big") << EColor256 << largeWidth << largeHeight << QColor(Qt::red);
+
+ // Direct Color Formats
+ QTest::newRow("EColor4K small") << EColor4K << smallWidth << smallHeight << QColor(Qt::red);
+ QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red);
+ QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green);
+ QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green);
+ QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red);
+ QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red);
+ QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0);
+ QTest::newRow("EColor16MA big opaque") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0);
+
+ // Semi-transparent Colors - Disabled for now, since the QCOMPARE fails, but visually confirmed to work
+// QTest::newRow("EColor16MA small semi") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 127);
+// QTest::newRow("EColor16MA big semi") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 127);
+// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0);
+// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0);
+
+#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+ QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red);
+ QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red);
+#endif
+}
+
+void tst_QPixmap::fromSymbianCFbsBitmap()
+{
+ QFETCH(TDisplayMode, format);
+ QFETCH(int, width);
+ QFETCH(int, height);
+ QFETCH(QColor, color);
+ int expectedDepth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(format);
+
+ CFbsBitmap *nativeBitmap = 0;
+ CFbsBitmapDevice *bitmapDevice = 0;
+ CBitmapContext *bitmapContext = 0;
+
+ nativeBitmap = new (ELeave) CFbsBitmap();
+ TInt err = nativeBitmap->Create(TSize(width, height), format);
+ CleanupStack::PushL(nativeBitmap);
+ QVERIFY(err == KErrNone);
+ bitmapDevice = CFbsBitmapDevice::NewL(nativeBitmap);
+ CleanupStack::PushL(bitmapDevice);
+
+ err = bitmapDevice->CreateBitmapContext(bitmapContext);
+ CleanupStack::PushL(bitmapContext);
+ QVERIFY(err == KErrNone);
+ TRgb symbianColor = TRgb(color.red(), color.green(), color.blue(), color.alpha());
+ bitmapContext->SetBrushColor(symbianColor);
+ bitmapContext->Clear();
+
+ __UHEAP_MARK;
+ { // Test the normal case
+ QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(nativeBitmap);
+// QCOMPARE(pixmap.depth(), expectedDepth); // Depth is not preserved now
+ QCOMPARE(pixmap.width(), width);
+ QCOMPARE(pixmap.height(), height);
+ QImage image = pixmap.toImage();
+
+ QColor actualColor(image.pixel(1, 1));
+ QCOMPARE(actualColor, color);
+ }
+ __UHEAP_MARKEND;
+
+ CleanupStack::PopAndDestroy(3);
+}
+#endif
+
void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()
{
#if !defined(Q_WS_WIN)