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>
This commit is contained in:
parent
3b8f828174
commit
d020d3f4ed
@ -47,6 +47,7 @@
|
|||||||
#include <qpa/qplatformintegration.h>
|
#include <qpa/qplatformintegration.h>
|
||||||
#include <qpa/qplatformaccessibility.h>
|
#include <qpa/qplatformaccessibility.h>
|
||||||
#include <QtGui/private/qguiapplication_p.h>
|
#include <QtGui/private/qguiapplication_p.h>
|
||||||
|
#include <QtGui/private/qhighdpiscaling_p.h>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && defined(interface)
|
#if defined(Q_OS_WIN) && defined(interface)
|
||||||
# undef interface
|
# undef interface
|
||||||
@ -301,6 +302,7 @@ void tst_QAccessibility::cleanup()
|
|||||||
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
|
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
|
||||||
}
|
}
|
||||||
QTestAccessibility::clearEvents();
|
QTestAccessibility::clearEvents();
|
||||||
|
QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAccessibility::eventTest()
|
void tst_QAccessibility::eventTest()
|
||||||
@ -3743,14 +3745,14 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
// Ideally it should be extended to test all aspects of the bridge.
|
// Ideally it should be extended to test all aspects of the bridge.
|
||||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||||
// First, test MSAA part of bridge
|
// First, test MSAA part of bridge
|
||||||
QWidget *window = new QWidget;
|
QWidget window;
|
||||||
QVBoxLayout *lay = new QVBoxLayout(window);
|
QVBoxLayout *lay = new QVBoxLayout(&window);
|
||||||
QPushButton *button = new QPushButton(tr("Push me"), window);
|
QPushButton *button = new QPushButton(tr("Push me"), &window);
|
||||||
QTextEdit *te = new QTextEdit(window);
|
QTextEdit *te = new QTextEdit(&window);
|
||||||
te->setText(QLatin1String("hello world\nhow are you today?\n"));
|
te->setText(QLatin1String("hello world\nhow are you today?\n"));
|
||||||
|
|
||||||
// Add QTableWidget
|
// Add QTableWidget
|
||||||
QTableWidget *tableWidget = new QTableWidget(3, 3, window);
|
QTableWidget *tableWidget = new QTableWidget(3, 3, &window);
|
||||||
tableWidget->setColumnCount(3);
|
tableWidget->setColumnCount(3);
|
||||||
QStringList hHeader;
|
QStringList hHeader;
|
||||||
hHeader << "h1" << "h2" << "h3";
|
hHeader << "h1" << "h2" << "h3";
|
||||||
@ -3776,8 +3778,8 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
lay->addWidget(tableWidget);
|
lay->addWidget(tableWidget);
|
||||||
lay->addWidget(label);
|
lay->addWidget(label);
|
||||||
|
|
||||||
window->show();
|
window.show();
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(window));
|
QVERIFY(QTest::qWaitForWindowExposed(&window));
|
||||||
|
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
@ -3789,9 +3791,8 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
QCOMPARE(buttonRect.topLeft(), buttonPos);
|
QCOMPARE(buttonRect.topLeft(), buttonPos);
|
||||||
|
|
||||||
// All set, now test the bridge.
|
// All set, now test the bridge.
|
||||||
POINT pt;
|
const QPoint nativePos = QHighDpi::toNativePixels(buttonRect.center(), window.windowHandle());
|
||||||
pt.x = buttonRect.center().x();
|
POINT pt{nativePos.x(), nativePos.y()};
|
||||||
pt.y = buttonRect.center().y();
|
|
||||||
IAccessible *iaccButton;
|
IAccessible *iaccButton;
|
||||||
|
|
||||||
VARIANT varChild;
|
VARIANT varChild;
|
||||||
@ -3817,7 +3818,7 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
QCOMPARE(SUCCEEDED(hr), false);
|
QCOMPARE(SUCCEEDED(hr), false);
|
||||||
|
|
||||||
hr = iaccButton->accLocation(&x, &y, &w, &h, varSELF);
|
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
|
#ifdef QT_SUPPORTS_IACCESSIBLE2
|
||||||
// Test IAccessible2 part of bridge
|
// Test IAccessible2 part of bridge
|
||||||
@ -3832,7 +3833,7 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
long x, y;
|
long x, y;
|
||||||
hr = ia2Component->get_locationInParent(&x, &y);
|
hr = ia2Component->get_locationInParent(&x, &y);
|
||||||
QVERIFY(SUCCEEDED(hr));
|
QVERIFY(SUCCEEDED(hr));
|
||||||
QCOMPARE(button->pos(), QPoint(x, y));
|
QCOMPARE(button->pos(), QHighDpi::fromNativePixels(QPoint(x, y), window.windowHandle()));
|
||||||
ia2Component->Release();
|
ia2Component->Release();
|
||||||
|
|
||||||
/***** Test IAccessibleAction *****/
|
/***** Test IAccessibleAction *****/
|
||||||
@ -3897,7 +3898,7 @@ void tst_QAccessibility::bridgeTest()
|
|||||||
/**************************************************
|
/**************************************************
|
||||||
* QWidget
|
* QWidget
|
||||||
**************************************************/
|
**************************************************/
|
||||||
QWindow *windowHandle = window->windowHandle();
|
QWindow *windowHandle = window.windowHandle();
|
||||||
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
|
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
|
||||||
HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", windowHandle);
|
HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", windowHandle);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user