diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-01 08:23:47 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-01 08:23:55 +0100 |
commit | 24cd4a71905a481d937cbd5c4cb9fb8bb91532c9 (patch) | |
tree | 67195b6b5fd1a1ddabc0f622082383ad65c94dfb /tests/auto/widgets | |
parent | aeb169a48869f4f50237e384e57ccb406228f620 (diff) | |
parent | 1dd0c4bf1af1c90fde1449a81d41acbc62cf1934 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: Ic7aaa06f4a14b1aed61faa1a6e7f527ee0eeb96b
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 26 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 |
2 files changed, 18 insertions, 14 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 63be3de3ab..6528c24c1a 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -555,6 +555,11 @@ void tst_QDialog::reject() QCOMPARE(dialog.called, 4); } +static QByteArray formatPoint(QPoint p) +{ + return QByteArray::number(p.x()) + ", " + QByteArray::number(p.y()); +} + void tst_QDialog::snapToDefaultButton() { #ifdef QT_NO_CURSOR @@ -563,9 +568,9 @@ void tst_QDialog::snapToDefaultButton() if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: Wayland does not support setting the cursor position."); - QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft(); - topLeftPos = QPoint(topLeftPos.x() + 100, topLeftPos.y() + 100); - QPoint startingPos(topLeftPos.x() + 250, topLeftPos.y() + 250); + const QRect dialogGeometry(QApplication::desktop()->availableGeometry().topLeft() + + QPoint(100, 100), QSize(200, 200)); + const QPoint startingPos = dialogGeometry.bottomRight() + QPoint(100, 100); QCursor::setPos(startingPos); #ifdef Q_OS_OSX // On OS X we use CGEventPost to move the cursor, it needs at least @@ -576,17 +581,14 @@ void tst_QDialog::snapToDefaultButton() QDialog dialog; QPushButton *button = new QPushButton(&dialog); button->setDefault(true); - dialog.setGeometry(QRect(topLeftPos, QSize(200, 200))); + dialog.setGeometry(dialogGeometry); dialog.show(); QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { - if (theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) { - QPoint localPos = button->mapFromGlobal(QCursor::pos()); - QVERIFY(button->rect().contains(localPos)); - } else { - QCOMPARE(startingPos, QCursor::pos()); - } - } + const QPoint localPos = button->mapFromGlobal(QCursor::pos()); + if (QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) + QVERIFY2(button->rect().contains(localPos), formatPoint(localPos).constData()); + else + QVERIFY2(!button->rect().contains(localPos), formatPoint(localPos).constData()); #endif // !QT_NO_CURSOR } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index afee548c9b..515ddf480f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4974,7 +4974,9 @@ static inline QByteArray msgRgbMismatch(unsigned actual, unsigned expected) static QPixmap grabWindow(QWindow *window, int x, int y, int width, int height) { QScreen *screen = window->screen(); - return screen ? screen->grabWindow(window->winId(), x, y, width, height) : QPixmap(); + Q_ASSERT(screen); + QPixmap result = screen->grabWindow(window->winId(), x, y, width, height); + return result.devicePixelRatio() > 1 ? result.scaled(width, height) : result; } #define VERIFY_COLOR(child, region, color) verifyColor(child, region, color, __LINE__) @@ -8500,7 +8502,7 @@ void tst_QWidget::translucentWidget() #ifdef Q_OS_WIN QWidget *desktopWidget = QApplication::desktop()->screen(0); if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) - widgetSnapshot = qApp->primaryScreen()->grabWindow(desktopWidget->winId(), labelPos.x(), labelPos.y(), label.width(), label.height()); + widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height()); else #endif widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); |