Make qpainter autotest build without widgets

Change-Id: I4e05871e44f7a69aaa9cd5d876c249c7dd9d86e8
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
Kent Hansen 2012-06-05 13:58:15 +02:00 committed by Qt by Nokia
parent 5951b61374
commit 3874022ec0
2 changed files with 31 additions and 2 deletions

View File

@ -2,7 +2,8 @@ CONFIG += testcase
CONFIG += parallel_test CONFIG += parallel_test
TARGET = tst_qpainter TARGET = tst_qpainter
QT += widgets widgets-private printsupport testlib QT += testlib
!contains(QT_CONFIG, no-widgets): QT += widgets widgets-private printsupport
SOURCES += tst_qpainter.cpp SOURCES += tst_qpainter.cpp

View File

@ -42,32 +42,42 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <qpainter.h> #include <qpainter.h>
#ifndef QT_NO_WIDGETS
#include <qdrawutil.h> #include <qdrawutil.h>
#include <qapplication.h> #include <qapplication.h>
#include <qwidget.h> #include <qwidget.h>
#endif
#include <qfontmetrics.h> #include <qfontmetrics.h>
#include <qbitmap.h> #include <qbitmap.h>
#include <qimage.h> #include <qimage.h>
#include <qthread.h> #include <qthread.h>
#include <limits.h> #include <limits.h>
#if !defined(Q_OS_WINCE) #if !defined(Q_OS_WINCE)
#ifndef QT_NO_WIDGETS
#include <qprinter.h> #include <qprinter.h>
#endif
#include <math.h> #include <math.h>
#endif #endif
#include <qpaintengine.h> #include <qpaintengine.h>
#ifndef QT_NO_WIDGETS
#include <qdesktopwidget.h> #include <qdesktopwidget.h>
#endif
#include <qpixmap.h> #include <qpixmap.h>
#include <qpainter.h> #include <qpainter.h>
#ifndef QT_NO_WIDGETS
#include <qlabel.h> #include <qlabel.h>
#endif
#include <qqueue.h> #include <qqueue.h>
#ifndef QT_NO_WIDGETS
#include <qgraphicsview.h> #include <qgraphicsview.h>
#include <qgraphicsscene.h> #include <qgraphicsscene.h>
#include <qgraphicsproxywidget.h> #include <qgraphicsproxywidget.h>
#include <qlayout.h> #include <qlayout.h>
#endif
#include <qfontdatabase.h> #include <qfontdatabase.h>
Q_DECLARE_METATYPE(QGradientStops) Q_DECLARE_METATYPE(QGradientStops)
@ -92,12 +102,16 @@ public slots:
void cleanupTestCase(); void cleanupTestCase();
private slots: private slots:
void getSetCheck(); void getSetCheck();
#ifndef QT_NO_WIDGETS
void drawPixmap_comp_data(); void drawPixmap_comp_data();
void drawPixmap_comp(); void drawPixmap_comp();
#endif
void saveAndRestore_data(); void saveAndRestore_data();
void saveAndRestore(); void saveAndRestore();
#ifndef QT_NO_WIDGETS
void drawBorderPixmap(); void drawBorderPixmap();
#endif
void drawPixmapFragments(); void drawPixmapFragments();
void drawLine_data(); void drawLine_data();
@ -136,7 +150,9 @@ private slots:
void qimageFormats(); void qimageFormats();
void textOnTransparentImage(); void textOnTransparentImage();
#ifndef QT_NO_WIDGETS
void initFrom(); void initFrom();
#endif
void setWindow(); void setWindow();
@ -173,7 +189,9 @@ private slots:
void drawhelper_blend_color(); void drawhelper_blend_color();
#ifndef QT_NO_WIDGETS
void childWidgetViewport(); void childWidgetViewport();
#endif
void fillRect_objectBoundingModeGradient(); void fillRect_objectBoundingModeGradient();
void fillRect_stretchToDeviceMode(); void fillRect_stretchToDeviceMode();
@ -246,7 +264,9 @@ private slots:
void setPenColorOnImage(); void setPenColorOnImage();
void setPenColorOnPixmap(); void setPenColorOnPixmap();
#ifndef QT_NO_WIDGETS
void QTBUG5939_attachPainterPrivate(); void QTBUG5939_attachPainterPrivate();
#endif
void drawPointScaled(); void drawPointScaled();
@ -350,7 +370,7 @@ Q_DECLARE_METATYPE(QRegion)
tst_QPainter::tst_QPainter() tst_QPainter::tst_QPainter()
{ {
// QtTestCase sets this to false, but this turns off alpha pixmaps on Unix. // QtTestCase sets this to false, but this turns off alpha pixmaps on Unix.
QApplication::setDesktopSettingsAware(true); QGuiApplication::setDesktopSettingsAware(true);
} }
tst_QPainter::~tst_QPainter() tst_QPainter::~tst_QPainter()
@ -417,6 +437,7 @@ static const char* const maskResult_data[] = {
"...ddddddddddddd"}; "...ddddddddddddd"};
#ifndef QT_NO_WIDGETS
void tst_QPainter::drawPixmap_comp_data() void tst_QPainter::drawPixmap_comp_data()
{ {
if (qApp->desktop()->depth() < 24) if (qApp->desktop()->depth() < 24)
@ -511,6 +532,7 @@ void tst_QPainter::drawPixmap_comp()
QVERIFY(!different); QVERIFY(!different);
} }
#endif
void tst_QPainter::saveAndRestore_data() void tst_QPainter::saveAndRestore_data()
{ {
@ -696,6 +718,7 @@ static QRect getPaintedSize(const QPixmap &pm, const QColor &background)
return getPaintedSize(pm.toImage(), background); return getPaintedSize(pm.toImage(), background);
} }
#ifndef QT_NO_WIDGETS
void tst_QPainter::initFrom() void tst_QPainter::initFrom()
{ {
QWidget *widget = new QWidget(); QWidget *widget = new QWidget();
@ -731,6 +754,7 @@ void tst_QPainter::drawBorderPixmap()
qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39), qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39),
QTileRules(Qt::StretchTile,Qt::StretchTile), 0); QTileRules(Qt::StretchTile,Qt::StretchTile), 0);
} }
#endif
void tst_QPainter::drawPixmapFragments() void tst_QPainter::drawPixmapFragments()
{ {
@ -2452,6 +2476,7 @@ void tst_QPainter::drawhelper_blend_color()
QCOMPARE(dest, expected); QCOMPARE(dest, expected);
} }
#ifndef QT_NO_WIDGETS
class ViewportTestWidget : public QWidget class ViewportTestWidget : public QWidget
{ {
public: public:
@ -2488,6 +2513,7 @@ void tst_QPainter::childWidgetViewport()
qWarning("Failed to ensure that paintEvent has been run. Could not run test."); qWarning("Failed to ensure that paintEvent has been run. Could not run test.");
} }
} }
#endif
void tst_QPainter::fillRect_objectBoundingModeGradient() void tst_QPainter::fillRect_objectBoundingModeGradient()
{ {
@ -4058,6 +4084,7 @@ void tst_QPainter::setPenColorOnPixmap()
setPenColor(p); setPenColor(p);
} }
#ifndef QT_NO_WIDGETS
class TestProxy : public QGraphicsProxyWidget class TestProxy : public QGraphicsProxyWidget
{ {
public: public:
@ -4106,6 +4133,7 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QVERIFY(widget->worldTransform.isIdentity()); QVERIFY(widget->worldTransform.isIdentity());
QCOMPARE(widget->deviceTransform, proxy->deviceTransform); QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
} }
#endif
void tst_QPainter::clipBoundingRect() void tst_QPainter::clipBoundingRect()
{ {