diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-10-30 13:45:18 +0100 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-11-04 20:11:22 +0000 |
commit | ad36da8ff416501e249beb098e5b84eaa2fba43d (patch) | |
tree | 48926e9edb976a5e804748a70ddb15d537e69e54 /tests/auto/widgets/widgets/qmenu | |
parent | 01f5f77c66dd6e4c15e0e0d8445e3560543e1973 (diff) |
testlib: start sharing common helper functions
... by moving them in QTestPrivate namespace (qtesthelpers_p.h). This
header file is a convenient staging area for helper APIs, eventually
some could be moved to public QTest API.
This header file utilizes the same pattern as other qtestlib header
files - wrapping functions with QT_${LIBNAME}_LIB to automatically
enable certain APIs based on what is in the projects dependencies,
e.g. QT += widgets.
Change-Id: Ic0266429939c1f3788912ad8b84fc6e0d5edd68b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qmenu')
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/qmenu.pro | 2 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 14 |
2 files changed, 4 insertions, 12 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro index 55fff01138..84b6530184 100644 --- a/tests/auto/widgets/widgets/qmenu/qmenu.pro +++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qmenu -QT += gui-private widgets testlib +QT += gui-private widgets testlib testlib-private SOURCES += tst_qmenu.cpp macx:{ OBJECTIVE_SOURCES += tst_qmenu_mac.mm diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index ad30db501a..99d29d487d 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <QtTest/private/qtesthelpers_p.h> #include <qapplication.h> #include <QPushButton> #include <QMainWindow> @@ -48,15 +49,11 @@ #include <qpa/qplatformtheme.h> +using namespace QTestPrivate; + Q_DECLARE_METATYPE(Qt::Key); Q_DECLARE_METATYPE(Qt::KeyboardModifiers); -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - struct MenuMetrics { int fw; int hmargin; @@ -71,11 +68,6 @@ struct MenuMetrics { } }; -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} - class tst_QMenu : public QObject { Q_OBJECT |