aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-07-11 12:06:15 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-07-11 12:57:13 +0200
commitd2d0e08e584c780b4b70a37e7b39c6bbcc7bc63e (patch)
tree22582b82dd5bb370205aa66302fb238bf5edaa6e /tests
parentc3431db7a3eb6b0c6e325e2d1e16eb6def9a4b4d (diff)
parent744164e6c92cb721d2a339cee8c465e1685723f9 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf tests/auto/controls/data/tst_scrollindicator.qml Change-Id: I1f5581ae7814c0d4152e4c9b79a30a8af5a3a17b
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/applicationwindow/data/focusAfterPopupClosed.qml15
-rw-r--r--tests/auto/applicationwindow/tst_applicationwindow.cpp44
-rw-r--r--tests/auto/controls/data/TumblerDatePicker.qml1
-rw-r--r--tests/auto/controls/data/tst_busyindicator.qml27
-rw-r--r--tests/auto/controls/data/tst_drawer.qml10
-rw-r--r--tests/auto/controls/data/tst_pageindicator.qml62
-rw-r--r--tests/auto/controls/data/tst_scrollindicator.qml27
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml39
-rw-r--r--tests/auto/popup/tst_popup.cpp34
9 files changed, 250 insertions, 9 deletions
diff --git a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
index 015e03bc..f0499a3a 100644
--- a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
+++ b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
@@ -57,9 +57,12 @@ ApplicationWindow {
visible: true
signal focusScopeKeyPressed
+ signal focusPopupKeyPressed
+ property alias fileMenu: fileMenu
property alias toolButton: toolButton
property alias focusScope: focusScope
+ property alias focusPopup: focusPopup
header: ToolBar {
ToolButton {
@@ -92,5 +95,17 @@ ApplicationWindow {
Keys.onSpacePressed: focusScopeKeyPressed()
}
+
+ Popup {
+ id: focusPopup
+ focus: true
+ width: parent.width
+ height: parent.height
+
+ Item {
+ focus: true
+ Keys.onSpacePressed: focusPopupKeyPressed()
+ }
+ }
}
diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp
index e04c9450..dd50caf0 100644
--- a/tests/auto/applicationwindow/tst_applicationwindow.cpp
+++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp
@@ -46,6 +46,8 @@
#include <QtQuickTemplates2/private/qquickoverlay_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquicklabel_p.h>
+#include <QtQuickTemplates2/private/qquickmenu_p.h>
+#include <QtQuickTemplates2/private/qquickpopup_p.h>
#include <QtQuickTemplates2/private/qquicktextarea_p.h>
#include <QtQuickTemplates2/private/qquicktextfield_p.h>
#include <QtQuickControls2/private/qquickproxytheme_p.h>
@@ -713,9 +715,9 @@ void tst_applicationwindow::focusAfterPopupClosed()
QVERIFY(focusScope);
QVERIFY(focusScope->hasActiveFocus());
- QSignalSpy spy(window.data(), SIGNAL(focusScopeKeyPressed()));
+ QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed()));
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(focusScopeSpy.count(), 1);
// Open the menu.
QQuickItem* toolButton = window->property("toolButton").value<QQuickItem*>();
@@ -726,14 +728,48 @@ void tst_applicationwindow::focusAfterPopupClosed()
// The FocusScope shouldn't receive any key events while the menu is open.
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(focusScopeSpy.count(), 1);
// Close the menu. The FocusScope should regain focus.
QTest::keyClick(window.data(), Qt::Key_Escape);
QVERIFY(focusScope->hasActiveFocus());
QTest::keyClick(window.data(), Qt::Key_Space);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(focusScopeSpy.count(), 2);
+
+ QQuickPopup *focusPopup = window->property("focusPopup").value<QQuickPopup*>();
+ QVERIFY(focusPopup);
+ QVERIFY(!focusPopup->hasActiveFocus());
+
+ focusPopup->open();
+ QVERIFY(focusPopup->isVisible());
+
+ QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed()));
+ QTest::keyClick(window.data(), Qt::Key_Space);
+ QCOMPARE(focusPopupSpy.count(), 1);
+
+ QQuickMenu *fileMenu = window->property("fileMenu").value<QQuickMenu*>();
+ QVERIFY(fileMenu);
+ fileMenu->open();
+ QVERIFY(fileMenu->isVisible());
+
+ // The Popup shouldn't receive any key events while the menu is open.
+ QTest::keyClick(window.data(), Qt::Key_Space);
+ QCOMPARE(focusPopupSpy.count(), 1);
+
+ // Close the menu. The Popup should regain focus.
+ QTest::keyClick(window.data(), Qt::Key_Escape);
+ QVERIFY(focusPopup->hasActiveFocus());
+
+ QTest::keyClick(window.data(), Qt::Key_Space);
+ QCOMPARE(focusPopupSpy.count(), 2);
+
+ // Close the popup. The FocusScope should regain focus.
+ QTest::keyClick(window.data(), Qt::Key_Escape);
+ QVERIFY(focusScope->hasActiveFocus());
+
+ QTest::keyClick(window.data(), Qt::Key_Space);
+ QCOMPARE(focusScopeSpy.count(), 3);
}
void tst_applicationwindow::clearFocusOnDestruction()
diff --git a/tests/auto/controls/data/TumblerDatePicker.qml b/tests/auto/controls/data/TumblerDatePicker.qml
index ac04284a..72e57bed 100644
--- a/tests/auto/controls/data/TumblerDatePicker.qml
+++ b/tests/auto/controls/data/TumblerDatePicker.qml
@@ -87,6 +87,7 @@ Row {
id: yearTumbler
objectName: "yearTumbler"
model: ListModel {
+ objectName: "yearTumblerListModel"
Component.onCompleted: {
for (var i = 2000; i < 2100; ++i) {
append({value: i.toString()});
diff --git a/tests/auto/controls/data/tst_busyindicator.qml b/tests/auto/controls/data/tst_busyindicator.qml
index 77a2d5ba..3de8c795 100644
--- a/tests/auto/controls/data/tst_busyindicator.qml
+++ b/tests/auto/controls/data/tst_busyindicator.qml
@@ -65,6 +65,11 @@ TestCase {
BusyIndicator { }
}
+ Component {
+ id: mouseArea
+ MouseArea { }
+ }
+
function test_running() {
var control = createTemporaryObject(busyIndicator, testCase)
verify(control)
@@ -73,4 +78,26 @@ TestCase {
control.running = false
compare(control.running, false)
}
+
+ // QTBUG-61785
+ function test_mouseArea() {
+ var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height})
+ verify(ma)
+
+ var control = busyIndicator.createObject(ma, {width: testCase.width, height: testCase.height})
+ verify(control)
+
+ mousePress(control)
+ verify(ma.pressed)
+
+ mouseRelease(control)
+ verify(!ma.pressed)
+
+ var touch = touchEvent(control)
+ touch.press(0, control).commit()
+ verify(ma.pressed)
+
+ touch.release(0, control).commit()
+ verify(!ma.pressed)
+ }
}
diff --git a/tests/auto/controls/data/tst_drawer.qml b/tests/auto/controls/data/tst_drawer.qml
index 617e7677..5446b969 100644
--- a/tests/auto/controls/data/tst_drawer.qml
+++ b/tests/auto/controls/data/tst_drawer.qml
@@ -73,6 +73,16 @@ TestCase {
compare(control.parent, Overlay.overlay)
}
+ function test_invalidEdge() {
+ var control = createTemporaryObject(drawer, testCase)
+ compare(control.edge, Qt.LeftEdge)
+
+ // Test an invalid value - it should warn and ignore it.
+ ignoreWarning(Qt.resolvedUrl("tst_drawer.qml") + ":65:9: QML Drawer: invalid edge value - valid values are: Qt.TopEdge, Qt.LeftEdge, Qt.RightEdge, Qt.BottomEdge")
+ control.edge = Drawer.Right
+ compare(control.edge, Qt.LeftEdge)
+ }
+
Component {
id: rectDrawer
diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml
index 86c0bd8b..70813cb8 100644
--- a/tests/auto/controls/data/tst_pageindicator.qml
+++ b/tests/auto/controls/data/tst_pageindicator.qml
@@ -65,6 +65,11 @@ TestCase {
PageIndicator { }
}
+ Component {
+ id: mouseArea
+ MouseArea { }
+ }
+
function test_count() {
var control = createTemporaryObject(pageIndicator, testCase)
verify(control)
@@ -83,20 +88,35 @@ TestCase {
compare(control.currentIndex, 5)
}
- function test_interactive() {
+ function test_interactive_data() {
+ return [
+ { tag: "mouse", touch: false },
+ { tag: "touch", touch: true }
+ ]
+ }
+
+ function test_interactive(data) {
var control = createTemporaryObject(pageIndicator, testCase, {count: 5, spacing: 10, padding: 10})
verify(control)
verify(!control.interactive)
compare(control.currentIndex, 0)
- mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton)
+ var touch = touchEvent(control)
+
+ if (data.touch)
+ touch.press(0, control).commit().release(0, control).commit()
+ else
+ mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(control.currentIndex, 0)
control.interactive = true
verify(control.interactive)
- mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton)
+ if (data.touch)
+ touch.press(0, control).commit().release(0, control).commit()
+ else
+ mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(control.currentIndex, 2)
// test also clicking outside delegates => the nearest should be selected
@@ -108,10 +128,44 @@ TestCase {
compare(control.currentIndex, -1)
var pos = control.mapFromItem(child, x, y)
- mouseClick(control, pos.x, pos.y, Qt.LeftButton)
+ if (data.touch)
+ touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit()
+ else
+ mouseClick(control, pos.x, pos.y, Qt.LeftButton)
compare(control.currentIndex, i)
}
}
}
}
+
+ function test_mouseArea_data() {
+ return [
+ { tag: "interactive", interactive: true },
+ { tag: "non-interactive", interactive: false }
+ ]
+ }
+
+ // QTBUG-61785
+ function test_mouseArea(data) {
+ var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height})
+ verify(ma)
+
+ var control = pageIndicator.createObject(ma, {count: 5, interactive: data.interactive, width: testCase.width, height: testCase.height})
+ verify(control)
+
+ compare(control.interactive, data.interactive)
+
+ mousePress(control)
+ compare(ma.pressed, !data.interactive)
+
+ mouseRelease(control)
+ verify(!ma.pressed)
+
+ var touch = touchEvent(control)
+ touch.press(0, control).commit()
+ compare(ma.pressed, !data.interactive)
+
+ touch.release(0, control).commit()
+ verify(!ma.pressed)
+ }
}
diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml
index 1e28c4f5..a6275f91 100644
--- a/tests/auto/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/controls/data/tst_scrollindicator.qml
@@ -66,6 +66,11 @@ TestCase {
}
Component {
+ id: mouseArea
+ MouseArea { }
+ }
+
+ Component {
id: flickable
Flickable {
width: 100
@@ -231,4 +236,26 @@ TestCase {
compare(control.horizontal, true)
compare(control.vertical, false)
}
+
+ // QTBUG-61785
+ function test_mouseArea() {
+ var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height})
+ verify(ma)
+
+ var control = scrollIndicator.createObject(ma, {active: true, size: 0.9, width: testCase.width, height: testCase.height})
+ verify(control)
+
+ mousePress(control)
+ verify(ma.pressed)
+
+ mouseRelease(control)
+ verify(!ma.pressed)
+
+ var touch = touchEvent(control)
+ touch.press(0, control).commit()
+ verify(ma.pressed)
+
+ touch.release(0, control).commit()
+ verify(!ma.pressed)
+ }
}
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 00d13e23..aaf888c2 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -389,7 +389,7 @@ TestCase {
compare(tumbler.monthTumbler.currentIndex, 0);
compare(tumbler.monthTumbler.count, 12);
compare(tumbler.yearTumbler.currentIndex, 0);
- compare(tumbler.yearTumbler.count, 100);
+ tryCompare(tumbler.yearTumbler, "count", 100);
verify(findView(tumbler.dayTumbler).children.length >= tumbler.dayTumbler.visibleItemCount);
verify(findView(tumbler.monthTumbler).children.length >= tumbler.monthTumbler.visibleItemCount);
@@ -1057,4 +1057,41 @@ TestCase {
compare(tumbler.moving, true)
tryCompare(tumbler, "moving", false)
}
+
+ Component {
+ id: qtbug61374Component
+
+ Row {
+ property alias tumbler: tumbler
+ property alias label: label
+
+ Component.onCompleted: {
+ tumbler.currentIndex = 2
+ }
+
+ Tumbler {
+ id: tumbler
+ model: 5
+ // ...
+ }
+
+ Label {
+ id: label
+ text: tumbler.currentItem.text
+ }
+ }
+ }
+
+ function test_qtbug61374() {
+ var row = createTemporaryObject(qtbug61374Component, testCase);
+ verify(row);
+
+ var tumbler = row.tumbler;
+ tryCompare(tumbler, "currentIndex", 2);
+
+ tumblerView = findView(tumbler);
+
+ var label = row.label;
+ compare(label.text, "2");
+ }
}
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index 48295e10..7566ceff 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -307,6 +307,40 @@ void tst_popup::overlay()
QVERIFY(!popup->isVisible());
QCOMPARE(overlay->isVisible(), popup->isVisible());
+
+ // multi-touch
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QVERIFY(overlay->isVisible());
+ QVERIFY(!button->isPressed());
+
+ QTest::touchEvent(window, device.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint());
+ QVERIFY(popup->isVisible());
+ QVERIFY(overlay->isVisible());
+ QCOMPARE(button->isPressed(), !modal);
+ QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+
+ QTest::touchEvent(window, device.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QVERIFY(popup->isVisible());
+ QVERIFY(overlay->isVisible());
+ QCOMPARE(button->isPressed(), !modal);
+ QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+
+ QTest::touchEvent(window, device.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1);
+ QVERIFY(!popup->isVisible());
+ QVERIFY(!overlay->isVisible());
+ QVERIFY(!button->isPressed());
+ QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
+
+ QTest::touchEvent(window, device.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QVERIFY(!popup->isVisible());
+ QVERIFY(!overlay->isVisible());
+ QVERIFY(!button->isPressed());
+ QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
}
void tst_popup::zOrder_data()