aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/qquickmenu
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-08-06 12:27:35 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-09-13 21:17:04 +0200
commite310dadef779b28845b41fb091634cd001cda9de (patch)
tree610be234e82cc53752f58521ae3beba4693ff78f /tests/auto/quickcontrols2/qquickmenu
parentde0c1c8a4c834dcc080d1b374186a82cd86921ca (diff)
Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quickcontrols2/qquickmenu')
-rw-r--r--tests/auto/quickcontrols2/qquickmenu/CMakeLists.txt5
-rw-r--r--tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp72
2 files changed, 42 insertions, 35 deletions
diff --git a/tests/auto/quickcontrols2/qquickmenu/CMakeLists.txt b/tests/auto/quickcontrols2/qquickmenu/CMakeLists.txt
index 20dcaca04a..14ef0a8fc4 100644
--- a/tests/auto/quickcontrols2/qquickmenu/CMakeLists.txt
+++ b/tests/auto/quickcontrols2/qquickmenu/CMakeLists.txt
@@ -12,9 +12,6 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qquickmenu
SOURCES
- ../shared/qtest_quickcontrols.h
- ../shared/util.cpp ../shared/util.h
- ../shared/visualtestutil.cpp ../shared/visualtestutil.h
tst_qquickmenu.cpp
DEFINES
QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/quickcontrols2\\\"
@@ -25,9 +22,11 @@ qt_internal_add_test(tst_qquickmenu
Qt::QmlPrivate
Qt::QuickControls2
Qt::QuickControls2Private
+ Qt::QuickControlsTestUtilsPrivate
Qt::QuickPrivate
Qt::QuickTemplates2Private
Qt::QuickTest
+ Qt::QuickTestUtilsPrivate
Qt::TestPrivate
TESTDATA ${test_data}
)
diff --git a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
index b3d91dc83e..4bb67e0321 100644
--- a/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/quickcontrols2/qquickmenu/tst_qquickmenu.cpp
@@ -43,9 +43,10 @@
#include <QtQml/qqmlcontext.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickitem_p.h>
-#include "../shared/util.h"
-#include "../shared/visualtestutil.h"
-#include "../shared/qtest_quickcontrols.h"
+#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/visualtestutils_p.h>
+#include <QtQuickControlsTestUtils/private/controlstestutils_p.h>
+#include <QtQuickControlsTestUtils/private/qtest_quickcontrols_p.h>
#include <QtQuickTemplates2/private/qquickaction_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
@@ -55,13 +56,15 @@
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
#include <QtQuickTemplates2/private/qquickmenuseparator_p.h>
-using namespace QQuickVisualTestUtil;
+using namespace QQuickVisualTestUtils;
+using namespace QQuickControlsTestUtils;
class tst_QQuickMenu : public QQmlDataTest
{
Q_OBJECT
public:
+ tst_QQuickMenu();
private slots:
void defaults();
@@ -104,9 +107,14 @@ private slots:
void giveMenuItemFocusOnButtonPress();
};
+tst_QQuickMenu::tst_QQuickMenu()
+ : QQmlDataTest(QT_QMLTEST_DATADIR)
+{
+}
+
void tst_QQuickMenu::defaults()
{
- QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value<QQuickMenu*>();
@@ -118,7 +126,7 @@ void tst_QQuickMenu::defaults()
void tst_QQuickMenu::count()
{
- QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickMenu *menu = helper.window->property("emptyMenu").value<QQuickMenu*>();
@@ -151,7 +159,7 @@ void tst_QQuickMenu::mouse()
|| (QGuiApplication::platformName() == QLatin1String("minimal")))
QSKIP("Mouse hovering not functional on offscreen/minimal platforms");
- QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
@@ -251,7 +259,7 @@ void tst_QQuickMenu::mouse()
void tst_QQuickMenu::pressAndHold()
{
- QQuickApplicationHelper helper(this, QLatin1String("pressAndHold.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("pressAndHold.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
@@ -276,7 +284,7 @@ void tst_QQuickMenu::contextMenuKeyboard()
if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
QSKIP("This platform only allows tab focus for text controls");
- QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
@@ -462,7 +470,7 @@ void tst_QQuickMenu::disabledMenuItemKeyNavigation()
if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
QSKIP("This platform only allows tab focus for text controls");
- QQuickApplicationHelper helper(this, QLatin1String("disabledMenuItemKeyNavigation.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("disabledMenuItemKeyNavigation.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
@@ -527,7 +535,7 @@ void tst_QQuickMenu::mnemonics()
QSKIP("Mnemonics are not used on macOS");
#endif
- QQuickApplicationHelper helper(this, QLatin1String("mnemonics.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("mnemonics.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
@@ -581,7 +589,7 @@ void tst_QQuickMenu::menuButton()
if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
QSKIP("This platform only allows tab focus for text controls");
- QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
@@ -608,7 +616,7 @@ void tst_QQuickMenu::menuButton()
void tst_QQuickMenu::addItem()
{
- QQuickApplicationHelper helper(this, QLatin1String("addItem.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("addItem.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -630,7 +638,7 @@ void tst_QQuickMenu::addItem()
void tst_QQuickMenu::menuSeparator()
{
- QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("menuSeparator.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
centerOnScreen(window);
@@ -708,7 +716,7 @@ void tst_QQuickMenu::menuSeparator()
void tst_QQuickMenu::repeater()
{
- QQuickApplicationHelper helper(this, QLatin1String("repeater.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("repeater.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -753,7 +761,7 @@ void tst_QQuickMenu::repeater()
void tst_QQuickMenu::order()
{
- QQuickApplicationHelper helper(this, QLatin1String("order.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("order.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -775,7 +783,7 @@ void tst_QQuickMenu::order()
void tst_QQuickMenu::popup()
{
- QQuickApplicationHelper helper(this, QLatin1String("popup.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("popup.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -932,7 +940,7 @@ void tst_QQuickMenu::popup()
void tst_QQuickMenu::actions()
{
- QQuickApplicationHelper helper(this, QLatin1String("actions.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("actions.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1001,7 +1009,7 @@ void tst_QQuickMenu::actions()
void tst_QQuickMenu::removeTakeItem()
{
- QQuickApplicationHelper helper(this, QLatin1String("removeTakeItem.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("removeTakeItem.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1059,7 +1067,7 @@ void tst_QQuickMenu::subMenuMouse()
QFETCH(bool, cascade);
- QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenus.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -1166,7 +1174,7 @@ void tst_QQuickMenu::subMenuDisabledMouse()
QFETCH(bool, cascade);
- QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -1229,7 +1237,7 @@ void tst_QQuickMenu::subMenuKeyboard()
QFETCH(bool, cascade);
QFETCH(bool, mirrored);
- QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenus.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -1355,7 +1363,7 @@ void tst_QQuickMenu::subMenuDisabledKeyboard()
QFETCH(bool, cascade);
QFETCH(bool, mirrored);
- QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -1441,7 +1449,7 @@ void tst_QQuickMenu::subMenuPosition()
QFETCH(bool, mirrored);
QFETCH(qreal, overlap);
- QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenus.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
@@ -1569,7 +1577,7 @@ void tst_QQuickMenu::subMenuPosition()
void tst_QQuickMenu::addRemoveSubMenus()
{
- QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("subMenus.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1641,7 +1649,7 @@ void tst_QQuickMenu::scrollable()
{
QFETCH(QString, qmlFilePath);
- QQuickApplicationHelper helper(this, qmlFilePath);
+ QQuickControlsApplicationHelper helper(this, qmlFilePath);
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1681,7 +1689,7 @@ void tst_QQuickMenu::disableWhenTriggered()
QFETCH(int, menuItemIndex);
QFETCH(int, subMenuItemIndex);
- QQuickApplicationHelper helper(this, QLatin1String("disableWhenTriggered.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("disableWhenTriggered.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1737,7 +1745,7 @@ void tst_QQuickMenu::menuItemWidth()
{
QFETCH(bool, mirrored);
- QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -1769,7 +1777,7 @@ void tst_QQuickMenu::menuItemWidthAfterMenuWidthChanged()
{
QFETCH(bool, mirrored);
- QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -1817,7 +1825,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged()
{
QFETCH(bool, mirrored);
- QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -1851,7 +1859,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged()
void tst_QQuickMenu::menuItemWidthAfterRetranslate()
{
- QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -1883,7 +1891,7 @@ void tst_QQuickMenu::menuItemWidthAfterRetranslate()
void tst_QQuickMenu::giveMenuItemFocusOnButtonPress()
{
- QQuickApplicationHelper helper(this, QLatin1String("giveMenuItemFocusOnButtonPress.qml"));
+ QQuickControlsApplicationHelper helper(this, QLatin1String("giveMenuItemFocusOnButtonPress.qml"));
QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();