These macros should only be called inside a test function, otherwise
they cannot abort the test function correctly. Solve this by making the
helper function return a boolean result (and output a warning on
failure to help with debugging) and verify the return value in each test
function that calls the helper.
Change-Id: I599673fda49051baf80a8c94b5d85a4d8c2cb406
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
tst_QStyle();
virtual ~tst_QStyle();
private:
tst_QStyle();
virtual ~tst_QStyle();
private:
- void testAllFunctions(QStyle *);
- void testScrollBarSubControls(QStyle *);
+ bool testAllFunctions(QStyle *);
+ bool testScrollBarSubControls(QStyle *);
void testPainting(QStyle *style, const QString &platform);
private slots:
void drawItemPixmap();
void testPainting(QStyle *style, const QString &platform);
private slots:
void drawItemPixmap();
QVERIFY(style->parent() == proxyStyle);
QVERIFY(proxyStyle->baseStyle() == style);
QVERIFY(style->parent() == proxyStyle);
QVERIFY(proxyStyle->baseStyle() == style);
- testAllFunctions(proxyStyle);
+ QVERIFY(testAllFunctions(proxyStyle));
proxyStyle->setBaseStyle(0);
QVERIFY(proxyStyle->baseStyle());
qApp->setStyle(proxyStyle);
QProxyStyle doubleProxy(new QProxyStyle(new QWindowsStyle()));
proxyStyle->setBaseStyle(0);
QVERIFY(proxyStyle->baseStyle());
qApp->setStyle(proxyStyle);
QProxyStyle doubleProxy(new QProxyStyle(new QWindowsStyle()));
- testAllFunctions(&doubleProxy);
+ QVERIFY(testAllFunctions(&doubleProxy));
CustomProxy customStyle;
QLineEdit edit;
CustomProxy customStyle;
QLineEdit edit;
-void tst_QStyle::testAllFunctions(QStyle *style)
+bool tst_QStyle::testAllFunctions(QStyle *style)
{
QStyleOption opt;
opt.init(testWidget);
{
QStyleOption opt;
opt.init(testWidget);
style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200));
style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test"));
style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200));
style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test"));
- testScrollBarSubControls(style);
+ return testScrollBarSubControls(style);
-void tst_QStyle::testScrollBarSubControls(QStyle* style)
+bool tst_QStyle::testScrollBarSubControls(QStyle* style)
+ // WinCE SmartPhone doesn't have scrollbar subcontrols, so skip the rest of the test.
#ifdef Q_OS_WINCE_WM
if (qobject_cast<QWindowsMobileStyle*>(style) && qt_wince_is_smartphone())
#ifdef Q_OS_WINCE_WM
if (qobject_cast<QWindowsMobileStyle*>(style) && qt_wince_is_smartphone())
- QSKIP("SmartPhone doesn't have scrollbar subcontrols.");
#else
Q_UNUSED(style);
#endif
#else
Q_UNUSED(style);
#endif
foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) {
QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SubControl(subControl), &scrollBar);
foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) {
QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SubControl(subControl), &scrollBar);
- QVERIFY(sr.isNull() == false);
+ if (sr.isNull()) {
+ qWarning("Null rect for subcontrol %d", subControl);
+ return false;
+ }
}
#ifndef QT_NO_STYLE_PLASTIQUE
void tst_QStyle::testPlastiqueStyle()
{
QPlastiqueStyle pstyle;
}
#ifndef QT_NO_STYLE_PLASTIQUE
void tst_QStyle::testPlastiqueStyle()
{
QPlastiqueStyle pstyle;
- testAllFunctions(&pstyle);
+ QVERIFY(testAllFunctions(&pstyle));
lineUpLayoutTest(&pstyle);
}
#endif
lineUpLayoutTest(&pstyle);
}
#endif
void tst_QStyle::testCleanlooksStyle()
{
QCleanlooksStyle cstyle;
void tst_QStyle::testCleanlooksStyle()
{
QCleanlooksStyle cstyle;
- testAllFunctions(&cstyle);
+ QVERIFY(testAllFunctions(&cstyle));
lineUpLayoutTest(&cstyle);
}
#endif
lineUpLayoutTest(&cstyle);
}
#endif
void tst_QStyle::testWindowsStyle()
{
QWindowsStyle wstyle;
void tst_QStyle::testWindowsStyle()
{
QWindowsStyle wstyle;
- testAllFunctions(&wstyle);
+ QVERIFY(testAllFunctions(&wstyle));
lineUpLayoutTest(&wstyle);
// Tests drawing indeterminate progress with 0 size: QTBUG-15973
lineUpLayoutTest(&wstyle);
// Tests drawing indeterminate progress with 0 size: QTBUG-15973
void tst_QStyle::testWindowsXPStyle()
{
QWindowsXPStyle xpstyle;
void tst_QStyle::testWindowsXPStyle()
{
QWindowsXPStyle xpstyle;
- testAllFunctions(&xpstyle);
+ QVERIFY(testAllFunctions(&xpstyle));
lineUpLayoutTest(&xpstyle);
}
#endif
lineUpLayoutTest(&xpstyle);
}
#endif
{
#if defined(Q_WS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA)
QWindowsVistaStyle vistastyle;
{
#if defined(Q_WS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA)
QWindowsVistaStyle vistastyle;
- testAllFunctions(&vistastyle);
+ QVERIFY(testAllFunctions(&vistastyle));
if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA)
testPainting(&vistastyle, "vista");
if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA)
testPainting(&vistastyle, "vista");
{
#ifdef Q_WS_MAC
QMacStyle mstyle;
{
#ifdef Q_WS_MAC
QMacStyle mstyle;
- testAllFunctions(&mstyle);
+ QVERIFY(testAllFunctions(&mstyle));
void tst_QStyle::testMotifStyle()
{
QMotifStyle mstyle;
void tst_QStyle::testMotifStyle()
{
QMotifStyle mstyle;
- testAllFunctions(&mstyle);
+ QVERIFY(testAllFunctions(&mstyle));
void tst_QStyle::testCDEStyle()
{
QCDEStyle cstyle;
void tst_QStyle::testCDEStyle()
{
QCDEStyle cstyle;
- testAllFunctions(&cstyle);
+ QVERIFY(testAllFunctions(&cstyle));
void tst_QStyle::testWindowsCEStyle()
{
QWindowsCEStyle cstyle;
void tst_QStyle::testWindowsCEStyle()
{
QWindowsCEStyle cstyle;
- testAllFunctions(&cstyle);
+ QVERIFY(testAllFunctions(&cstyle));
void tst_QStyle::testWindowsMobileStyle()
{
QWindowsMobileStyle cstyle;
void tst_QStyle::testWindowsMobileStyle()
{
QWindowsMobileStyle cstyle;
- testAllFunctions(&cstyle);
+ QVERIFY(testAllFunctions(&cstyle));