Windows: Fix some widget tests to pass on High DPI screens

For tst_QFrame and tst_QOpenGLWidget, force scaling off
since they do screen captures which would fail with
scaling activated due to different device pixel ratios.

For tst_QGraphicsItem and tst_QHeaderView, force
scaling on for Windows since some tests otherwise fail
due to violation of the minimum size constraints of
framed windows on Windows.

The tests will then pass regardless of any environment
setting of the scaling variables on a developer
machine.

Change-Id: Iefa4e84b433f7e51dce4e416546a9eda8ee6d0f1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Friedemann Kleint 2019-08-14 15:55:31 +02:00
parent 3f603906b4
commit a4a1198708
4 changed files with 27 additions and 0 deletions

View File

@ -272,6 +272,9 @@ class tst_QGraphicsItem : public QObject
{
Q_OBJECT
public:
static void initMain();
private slots:
void construction();
void constructionWithParent();
@ -474,6 +477,14 @@ private:
QTouchDevice *m_touchDevice = nullptr;
};
void tst_QGraphicsItem::initMain()
{
#ifdef Q_OS_WIN
// Ensure minimum size constraints of framed windows on High DPI screens
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
}
void tst_QGraphicsItem::construction()
{
for (int i = 0; i < 7; ++i) {

View File

@ -106,6 +106,7 @@ class tst_QHeaderView : public QObject
public:
tst_QHeaderView();
static void initMain();
private slots:
void initTestCase();
@ -265,6 +266,14 @@ protected:
QElapsedTimer timer;
};
void tst_QHeaderView::initMain()
{
#ifdef Q_OS_WIN
// Ensure minimum size constraints of framed windows on High DPI screens
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
}
class QtTestModel: public QAbstractTableModel
{

View File

@ -37,6 +37,10 @@
class tst_QFrame : public QObject
{
Q_OBJECT
public:
static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); }
private slots:
void testDefaults();
void testInitStyleOption_data();

View File

@ -49,6 +49,9 @@ class tst_QOpenGLWidget : public QObject
{
Q_OBJECT
public:
static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); }
private slots:
void initTestCase();
void create();