diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-08-07 13:53:05 -0700 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-08 11:48:10 +0200 |
commit | 883dfb3d156431eeb3ffc8f02a09c89bb7fa7d46 (patch) | |
tree | d4c2b3d096e1d5c64be698b5d0cd8c8bae35b2b4 /tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp | |
parent | 5a9b1425e187bc77122354cf7446bcf6bb322ff4 (diff) | |
parent | b75bc0f75c09b192dba68449b009cdf175519dbd (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/widgets/kernel/qwidget.cpp
This merge also extends the expected output of the pairdiagnostics
teamcity output (added in dev in commit
c608ffc56ab37f9a9d5b9c34543126adb89e2b08) after the recent addition of
the flowId attribute to the teamcity output (commit
8f036562119dd35ce51dc9230304d893b906bd37 in 5.9).
Change-Id: I3868166e5efc45538544fffd14d8aba438f9173c
Diffstat (limited to 'tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp')
-rw-r--r-- | tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index 52183efb82..37d97cd3db 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -31,12 +31,17 @@ #include <QEvent> #include <QtCore/qthread.h> #include <QtGui/qguiapplication.h> +#include <QtGui/qpainter.h> +#include <QtGui/qrasterwindow.h> #include <QtNetwork/qtcpserver.h> #include <QtNetwork/qtcpsocket.h> #include <QtCore/qelapsedtimer.h> #include <QtCore/qt_windows.h> +static const int topVerticalMargin = 50; +static const int margin = 10; + class tst_NoQtEventLoop : public QObject { Q_OBJECT @@ -47,10 +52,10 @@ private slots: }; -class Window : public QWindow +class Window : public QRasterWindow { public: - Window(QWindow *parentWindow = 0) : QWindow(parentWindow) + explicit Window(QWindow *parentWindow = nullptr) : QRasterWindow(parentWindow) { } @@ -72,6 +77,13 @@ public: QHash<QEvent::Type, int> m_received; + +protected: + void paintEvent(QPaintEvent *) override + { + QPainter p(this); + p.fillRect(QRect(QPoint(0, 0), size()), Qt::yellow); + } }; bool g_exit = false; @@ -174,7 +186,8 @@ public: QTRY_COMPARE(m_childWindow->received(QEvent::MouseButtonPress) + m_childWindow->received(QEvent::MouseButtonRelease), 0); // Now click in the QWindow. The QWindow should receive those events. - m_windowPos.ry() += 50; + m_windowPos.rx() += margin; + m_windowPos.ry() += topVerticalMargin; mouseMove(m_windowPos); ::Sleep(150); mouseClick(); @@ -204,6 +217,8 @@ void tst_NoQtEventLoop::consumeMouseEvents() { int argc = 1; char *argv[] = {const_cast<char*>("test")}; + // ensure scaling is off since the child window is positioned using QWindow API. + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); QGuiApplication app(argc, argv); QString clsName(QStringLiteral("tst_NoQtEventLoop_WINDOW")); const HINSTANCE appInstance = (HINSTANCE)GetModuleHandle(0); @@ -225,16 +240,28 @@ void tst_NoQtEventLoop::consumeMouseEvents() QVERIFY2(atom, "RegisterClassEx failed"); DWORD dwExStyle = WS_EX_APPWINDOW; - DWORD dwStyle = WS_CAPTION | WS_HSCROLL | WS_TABSTOP | WS_VISIBLE; - - HWND mainWnd = ::CreateWindowEx(dwExStyle, (wchar_t*)clsName.utf16(), TEXT("tst_NoQtEventLoop"), dwStyle, 100, 100, 300, 300, 0, NULL, appInstance, NULL); + DWORD dwStyle = WS_CAPTION | WS_TABSTOP | WS_VISIBLE; + + const int screenWidth = ::GetSystemMetrics(SM_CXSCREEN); + const int screenHeight = ::GetSystemMetrics(SM_CYSCREEN); + const int width = screenWidth / 4; + const int height = screenHeight / 4; + + HWND mainWnd = + ::CreateWindowEx(dwExStyle, reinterpret_cast<const wchar_t*>(clsName.utf16()), + TEXT("tst_NoQtEventLoop"), dwStyle, + (screenWidth - width) / 2, (screenHeight - height) / 2 , width, height, + 0, NULL, appInstance, NULL); QVERIFY2(mainWnd, "CreateWindowEx failed"); ::ShowWindow(mainWnd, SW_SHOW); + ::SetWindowPos(mainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + Window *childWindow = new Window; childWindow->setParent(QWindow::fromWinId((WId)mainWnd)); - childWindow->setGeometry(0, 50, 200, 200); + childWindow->setGeometry(margin, topVerticalMargin, + width - 2 * margin, height - margin - topVerticalMargin); childWindow->show(); TestThread *testThread = new TestThread(mainWnd, childWindow); |