summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-18 10:17:54 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-24 16:43:56 +0000
commitd020d3f4ede280d998e3b7069a39e134dc9319a5 (patch)
tree4061d434b2da26297ef3159d2d757189fe843f11 /tests
parent3b8f828174f08d9037a0947b8709648ac37cdc36 (diff)
Stabilize tst_qaccessibility
Ensure windows are cleaned up. Add scaling where native coordinates are used. Task-number: QTQAINFRA-1440 Change-Id: Ie080ff780c687418f4dc5d71fd49112486b217e6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 4ffdc4c762..b857501e8f 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -47,6 +47,7 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformaccessibility.h>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
#if defined(Q_OS_WIN) && defined(interface)
# undef interface
@@ -301,6 +302,7 @@ void tst_QAccessibility::cleanup()
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
}
QTestAccessibility::clearEvents();
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QAccessibility::eventTest()
@@ -3743,14 +3745,14 @@ void tst_QAccessibility::bridgeTest()
// Ideally it should be extended to test all aspects of the bridge.
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// First, test MSAA part of bridge
- QWidget *window = new QWidget;
- QVBoxLayout *lay = new QVBoxLayout(window);
- QPushButton *button = new QPushButton(tr("Push me"), window);
- QTextEdit *te = new QTextEdit(window);
+ QWidget window;
+ QVBoxLayout *lay = new QVBoxLayout(&window);
+ QPushButton *button = new QPushButton(tr("Push me"), &window);
+ QTextEdit *te = new QTextEdit(&window);
te->setText(QLatin1String("hello world\nhow are you today?\n"));
// Add QTableWidget
- QTableWidget *tableWidget = new QTableWidget(3, 3, window);
+ QTableWidget *tableWidget = new QTableWidget(3, 3, &window);
tableWidget->setColumnCount(3);
QStringList hHeader;
hHeader << "h1" << "h2" << "h3";
@@ -3776,8 +3778,8 @@ void tst_QAccessibility::bridgeTest()
lay->addWidget(tableWidget);
lay->addWidget(label);
- window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
/**************************************************
@@ -3789,9 +3791,8 @@ void tst_QAccessibility::bridgeTest()
QCOMPARE(buttonRect.topLeft(), buttonPos);
// All set, now test the bridge.
- POINT pt;
- pt.x = buttonRect.center().x();
- pt.y = buttonRect.center().y();
+ const QPoint nativePos = QHighDpi::toNativePixels(buttonRect.center(), window.windowHandle());
+ POINT pt{nativePos.x(), nativePos.y()};
IAccessible *iaccButton;
VARIANT varChild;
@@ -3817,7 +3818,7 @@ void tst_QAccessibility::bridgeTest()
QCOMPARE(SUCCEEDED(hr), false);
hr = iaccButton->accLocation(&x, &y, &w, &h, varSELF);
- QCOMPARE(buttonRect, QRect(x, y, w, h));
+ QCOMPARE(buttonRect, QHighDpi::fromNativePixels(QRect(x, y, w, h), window.windowHandle()));
#ifdef QT_SUPPORTS_IACCESSIBLE2
// Test IAccessible2 part of bridge
@@ -3832,7 +3833,7 @@ void tst_QAccessibility::bridgeTest()
long x, y;
hr = ia2Component->get_locationInParent(&x, &y);
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(button->pos(), QPoint(x, y));
+ QCOMPARE(button->pos(), QHighDpi::fromNativePixels(QPoint(x, y), window.windowHandle()));
ia2Component->Release();
/***** Test IAccessibleAction *****/
@@ -3897,7 +3898,7 @@ void tst_QAccessibility::bridgeTest()
/**************************************************
* QWidget
**************************************************/
- QWindow *windowHandle = window->windowHandle();
+ QWindow *windowHandle = window.windowHandle();
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", windowHandle);