diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-12-09 15:37:01 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-12-10 09:48:26 +0000 |
commit | eb500f9cd9756f035b3d74b3a58a1a78e229988d (patch) | |
tree | d7bf456602afe72107301dfc23ac03af2f9e6597 /tests | |
parent | 3b7fb484d5dd99181c62f520b8317c6439d059a6 (diff) |
Move ApplicationHelper to visualtestutil.h and rename it
This class is useful for other auto tests, like Popup's.
Change-Id: Ie193c07e5b53b67493fceba9a1c32798db2f4e34
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/menu/tst_menu.cpp | 30 | ||||
-rw-r--r-- | tests/auto/shared/util.pri | 2 | ||||
-rw-r--r-- | tests/auto/shared/visualtestutil.h | 26 |
3 files changed, 31 insertions, 27 deletions
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index 5823767a..7b2b8ea6 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -52,28 +52,6 @@ using namespace QQuickVisualTestUtil; -class ApplicationHelper -{ -public: - ApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath = QLatin1String("applicationwindow.qml")) : - component(&engine) - { - component.loadUrl(testCase->testFileUrl(testFilePath)); - QObject *rootObject = component.create(); - cleanup.reset(rootObject); - QVERIFY2(rootObject, qPrintable(QString::fromLatin1("Failed to create ApplicationWindow: %1").arg(component.errorString()))); - - window = qobject_cast<QQuickApplicationWindow*>(rootObject); - QVERIFY(window); - QVERIFY(!window->isVisible()); - } - - QQmlEngine engine; - QQmlComponent component; - QScopedPointer<QObject> cleanup; - QQuickApplicationWindow *window; -}; - class tst_menu : public QQmlDataTest { Q_OBJECT @@ -89,7 +67,7 @@ private slots: void tst_menu::defaults() { - ApplicationHelper helper(this); + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); QQuickMenu *emptyMenu = helper.window->property("emptyMenu").value<QQuickMenu*>(); QCOMPARE(emptyMenu->isVisible(), false); @@ -98,7 +76,7 @@ void tst_menu::defaults() void tst_menu::mouse() { - ApplicationHelper helper(this); + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); QQuickApplicationWindow *window = helper.window; window->show(); @@ -170,7 +148,7 @@ void tst_menu::contextMenuKeyboard() if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) QSKIP("This platform only allows tab focus for text controls"); - ApplicationHelper helper(this); + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); QQuickApplicationWindow *window = helper.window; window->show(); @@ -248,7 +226,7 @@ void tst_menu::menuButton() if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) QSKIP("This platform only allows tab focus for text controls"); - ApplicationHelper helper(this); + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); QQuickApplicationWindow *window = helper.window; window->show(); diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri index 747bdf64..5e6b06b6 100644 --- a/tests/auto/shared/util.pri +++ b/tests/auto/shared/util.pri @@ -1,4 +1,4 @@ -QT += core-private gui-private qml-private quick-private +QT += core-private gui-private qml-private quick-private labstemplates-private HEADERS += $$PWD/visualtestutil.h \ $$PWD/util.h diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h index 7a35ac76..b3fecf8e 100644 --- a/tests/auto/shared/visualtestutil.h +++ b/tests/auto/shared/visualtestutil.h @@ -42,6 +42,10 @@ #include <QtQuick/private/qquickitem_p.h> +#include <QtLabsTemplates/private/qquickapplicationwindow_p.h> + +#include "util.h" + namespace QQuickVisualTestUtil { QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName); @@ -104,6 +108,28 @@ namespace QQuickVisualTestUtil items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i])); return items; } + + class QQuickApplicationHelper + { + public: + QQuickApplicationHelper(QQmlDataTest *testCase, const QString &testFilePath) : + component(&engine) + { + component.loadUrl(testCase->testFileUrl(testFilePath)); + QObject *rootObject = component.create(); + cleanup.reset(rootObject); + QVERIFY2(rootObject, qPrintable(QString::fromLatin1("Failed to create ApplicationWindow: %1").arg(component.errorString()))); + + window = qobject_cast<QQuickApplicationWindow*>(rootObject); + QVERIFY(window); + QVERIFY(!window->isVisible()); + } + + QQmlEngine engine; + QQmlComponent component; + QScopedPointer<QObject> cleanup; + QQuickApplicationWindow *window; + }; } #define QQUICK_VERIFY_POLISH(item) \ |