Skip to content

Commit

Permalink
Fix build failure on OSX+cmake due to Q_OS_MAC not defined during moc
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaure-kdab committed Jan 18, 2019
1 parent 1c79397 commit bf9fd1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions unittests/SpreadsheetMode/SpreadsheetMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ private slots:
#endif
}

#ifndef Q_OS_MAC // disabled on Mac due to a different DPI value. The code should be portable anyway :)
void fontScalerShouldScaleForHeight()
{
#ifndef Q_OS_MAC // disabled on Mac due to a different DPI value. The code should be portable anyway :)
SKIP_IF_FONT_NOT_FOUND

QFont f(s_fontName);
Expand Down Expand Up @@ -160,11 +160,13 @@ private slots:
// On Windows we can get 2, though.
scaler.setFactorForHeight(2.9);
QVERIFY2(scaler.fontMetrics().height() <= 4, qPrintable(QString::number(scaler.fontMetrics().height())));
#endif
#endif
}

void fontScalerShouldScaleForWidth()
{
#ifndef Q_OS_MAC // disabled on Mac due to a different DPI value. The code should be portable anyway :)
SKIP_IF_FONT_NOT_FOUND

QFont f(s_fontName);
Expand All @@ -187,10 +189,12 @@ private slots:
QVERIFY2(scaledWidth <= wantedWidth, qPrintable(QString::number(scaledWidth)));
QVERIFY2(scaledWidth > wantedWidth - 6, qPrintable(QString::number(scaledWidth)));
}
#endif
}

void testFontScalerFontIssues()
{
#ifndef Q_OS_MAC // disabled on Mac due to a different DPI value. The code should be portable anyway :)
QFont f(s_fontName, 8);
FontScaler scaler(f);
QFontMetricsF fm(f);
Expand All @@ -202,9 +206,9 @@ private slots:
fm = scaler.fontMetrics();
const qreal finalWidth = fm.width(text);
QVERIFY2(finalWidth <= expectedWidth, QString("finalWidth=%1 bigger than expectedWidth=%2").arg(finalWidth).arg(expectedWidth).toLatin1().constData());
#endif
}

#endif

// Test that we don't hit an infinite loop when trying to use setFactorForWidth
// with a very small number.
Expand Down

0 comments on commit bf9fd1e

Please sign in to comment.