aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-03 15:15:53 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-05 11:03:54 +0000
commita0d77ff082b6a5aa02a36f5a82649c45c0dcd265 (patch)
tree7c711e3311612d1d8633d7af503a29f81cb49c45
parent28daf8cc73c6ba51bcdda3079d73c2db7919fc2a (diff)
auto tests: allow using QQuickWindow with QQuickApplicationHelper
This allows us to run the relevant popup tests for both QQuickWindow and QQuickApplicationWindow. Change-Id: I14b6435afeeb8a6cf640d8c52ad1d9e1fae070b0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--tests/auto/drawer/tst_drawer.cpp20
-rw-r--r--tests/auto/menu/tst_menu.cpp10
-rw-r--r--tests/auto/popup/tst_popup.cpp44
-rw-r--r--tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp2
-rw-r--r--tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp2
-rw-r--r--tests/auto/shared/visualtestutil.h8
6 files changed, 44 insertions, 42 deletions
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 3c128fbc..ffa1f896 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -86,12 +86,12 @@ void tst_Drawer::position()
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>();
+ QQuickDrawer *drawer = helper.appWindow->property("drawer").value<QQuickDrawer*>();
QVERIFY(drawer);
drawer->setEdge(edge);
@@ -131,12 +131,12 @@ void tst_Drawer::dragMargin()
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>();
+ QQuickDrawer *drawer = helper.appWindow->property("drawer").value<QQuickDrawer*>();
QVERIFY(drawer);
drawer->setEdge(edge);
drawer->setDragMargin(dragMargin);
@@ -167,12 +167,12 @@ void tst_Drawer::reposition()
{
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>();
+ QQuickDrawer *drawer = helper.appWindow->property("drawer").value<QQuickDrawer*>();
QVERIFY(drawer);
drawer->setEdge(Qt::RightEdge);
@@ -199,20 +199,20 @@ void tst_Drawer::hover()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, QStringLiteral("hover.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>();
+ QQuickDrawer *drawer = helper.appWindow->property("drawer").value<QQuickDrawer*>();
QVERIFY(drawer);
drawer->setModal(modal);
- QQuickButton *backgroundButton = helper.window->property("backgroundButton").value<QQuickButton*>();
+ QQuickButton *backgroundButton = helper.appWindow->property("backgroundButton").value<QQuickButton*>();
QVERIFY(backgroundButton);
backgroundButton->setHoverEnabled(true);
- QQuickButton *drawerButton = helper.window->property("drawerButton").value<QQuickButton*>();
+ QQuickButton *drawerButton = helper.appWindow->property("drawerButton").value<QQuickButton*>();
QVERIFY(drawerButton);
drawerButton->setHoverEnabled(true);
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp
index dc9c296a..7617cfcc 100644
--- a/tests/auto/menu/tst_menu.cpp
+++ b/tests/auto/menu/tst_menu.cpp
@@ -71,7 +71,7 @@ void tst_menu::defaults()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickMenu *emptyMenu = helper.window->property("emptyMenu").value<QQuickMenu*>();
+ QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value<QQuickMenu*>();
QCOMPARE(emptyMenu->isVisible(), false);
QCOMPARE(emptyMenu->contentItem()->property("currentIndex"), QVariant(-1));
}
@@ -80,7 +80,7 @@ void tst_menu::mouse()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -152,7 +152,7 @@ void tst_menu::contextMenuKeyboard()
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -230,7 +230,7 @@ void tst_menu::menuButton()
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -254,7 +254,7 @@ void tst_menu::menuButton()
void tst_menu::addItem()
{
QQuickApplicationHelper helper(this, QLatin1String("addItem.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index 1166b517..abd20df0 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -68,12 +68,12 @@ void tst_popup::visible()
{
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
QQuickItem *popupItem = popup->popupItem();
@@ -98,7 +98,7 @@ void tst_popup::overlay()
{
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -115,10 +115,10 @@ void tst_popup::overlay()
QCOMPARE(overlayPressedSignal.count(), 0);
QCOMPARE(overlayReleasedSignal.count(), 0);
- QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
- QQuickButton *button = helper.window->property("button").value<QQuickButton*>();
+ QQuickButton *button = helper.appWindow->property("button").value<QQuickButton*>();
QVERIFY(button);
popup->open();
@@ -160,16 +160,16 @@ void tst_popup::zOrder()
{
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
popup->setModal(true);
- QQuickPopup *popup2 = helper.window->property("popup2").value<QQuickPopup*>();
+ QQuickPopup *popup2 = helper.appWindow->property("popup2").value<QQuickPopup*>();
QVERIFY(popup2);
popup2->setModal(true);
@@ -237,15 +237,15 @@ void tst_popup::closePolicy()
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
- QQuickButton *button = helper.window->property("button").value<QQuickButton*>();
+ QQuickButton *button = helper.appWindow->property("button").value<QQuickButton*>();
QVERIFY(button);
popup->setModal(true);
@@ -308,15 +308,15 @@ void tst_popup::activeFocusOnClose1()
// Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect
// the active focus item when it closes.
QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *focusedPopup = helper.window->property("focusedPopup").value<QQuickPopup*>();
+ QQuickPopup *focusedPopup = helper.appWindow->property("focusedPopup").value<QQuickPopup*>();
QVERIFY(focusedPopup);
- QQuickPopup *nonFocusedPopup = helper.window->property("nonFocusedPopup").value<QQuickPopup*>();
+ QQuickPopup *nonFocusedPopup = helper.appWindow->property("nonFocusedPopup").value<QQuickPopup*>();
QVERIFY(nonFocusedPopup);
focusedPopup->open();
@@ -338,18 +338,18 @@ void tst_popup::activeFocusOnClose2()
// calling forceActiveFocus() on another item) before it closes doesn't
// affect the active focus item when it closes.
QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose2.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *popup1 = helper.window->property("popup1").value<QQuickPopup*>();
+ QQuickPopup *popup1 = helper.appWindow->property("popup1").value<QQuickPopup*>();
QVERIFY(popup1);
- QQuickPopup *popup2 = helper.window->property("popup2").value<QQuickPopup*>();
+ QQuickPopup *popup2 = helper.appWindow->property("popup2").value<QQuickPopup*>();
QVERIFY(popup2);
- QQuickButton *closePopup2Button = helper.window->property("closePopup2Button").value<QQuickButton*>();
+ QQuickButton *closePopup2Button = helper.appWindow->property("closePopup2Button").value<QQuickButton*>();
QVERIFY(closePopup2Button);
popup1->open();
@@ -380,20 +380,20 @@ void tst_popup::hover()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, QStringLiteral("hover.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
- QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QQuickPopup *popup = helper.appWindow->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
popup->setModal(modal);
- QQuickButton *parentButton = helper.window->property("parentButton").value<QQuickButton*>();
+ QQuickButton *parentButton = helper.appWindow->property("parentButton").value<QQuickButton*>();
QVERIFY(parentButton);
parentButton->setHoverEnabled(true);
- QQuickButton *childButton = helper.window->property("childButton").value<QQuickButton*>();
+ QQuickButton *childButton = helper.appWindow->property("childButton").value<QQuickButton*>();
QVERIFY(childButton);
childButton->setHoverEnabled(true);
diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
index c7670c21..c0db7c49 100644
--- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
+++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
@@ -55,7 +55,7 @@ void tst_qquickmaterialstyleconf::conf()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
// We specified a custom background color, so the window should have it.
diff --git a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
index c676ae6d..ce018a05 100644
--- a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
+++ b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
@@ -55,7 +55,7 @@ void tst_qquickuniversalstyleconf::conf()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
- QQuickApplicationWindow *window = helper.window;
+ QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
// We specified a custom background color, so the window should have it.
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h
index c1cc9c7d..c67e5bdc 100644
--- a/tests/auto/shared/visualtestutil.h
+++ b/tests/auto/shared/visualtestutil.h
@@ -118,9 +118,10 @@ namespace QQuickVisualTestUtil
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())));
+ QVERIFY2(rootObject, qPrintable(QString::fromLatin1("Failed to create window: %1").arg(component.errorString())));
- window = qobject_cast<QQuickApplicationWindow*>(rootObject);
+ window = qobject_cast<QQuickWindow*>(rootObject);
+ appWindow = qobject_cast<QQuickApplicationWindow*>(rootObject);
QVERIFY(window);
QVERIFY(!window->isVisible());
}
@@ -128,7 +129,8 @@ namespace QQuickVisualTestUtil
QQmlEngine engine;
QQmlComponent component;
QScopedPointer<QObject> cleanup;
- QQuickApplicationWindow *window;
+ QQuickApplicationWindow *appWindow;
+ QQuickWindow *window;
};
}