From d020d3f4ede280d998e3b7069a39e134dc9319a5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Sep 2017 10:17:54 +0200 Subject: Stabilize tst_qaccessibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Frederik Gladhorn --- .../other/qaccessibility/tst_qaccessibility.cpp | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'tests') 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 #include #include +#include #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); -- cgit v1.2.3