diff options
Diffstat (limited to 'tests')
86 files changed, 2376 insertions, 806 deletions
diff --git a/tests/auto/accessibility/data/abstractbutton.qml b/tests/auto/accessibility/data/abstractbutton.qml new file mode 100644 index 00000000..368f4582 --- /dev/null +++ b/tests/auto/accessibility/data/abstractbutton.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +AbstractButton { + text: "AbstractButton" +} diff --git a/tests/auto/accessibility/data/busyindicator.qml b/tests/auto/accessibility/data/busyindicator.qml index 4bde9634..b15ea80a 100644 --- a/tests/auto/accessibility/data/busyindicator.qml +++ b/tests/auto/accessibility/data/busyindicator.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - BusyIndicator { - id: busyindicator - objectName: "busyindicator" - } -} +BusyIndicator { } diff --git a/tests/auto/accessibility/data/button.qml b/tests/auto/accessibility/data/button.qml index 75925185..0fd14210 100644 --- a/tests/auto/accessibility/data/button.qml +++ b/tests/auto/accessibility/data/button.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Button { - id: button - objectName: "button" - text: "Button" - } +Button { + text: "Button" } diff --git a/tests/auto/accessibility/data/checkbox.qml b/tests/auto/accessibility/data/checkbox.qml index 9700663d..e70d7d83 100644 --- a/tests/auto/accessibility/data/checkbox.qml +++ b/tests/auto/accessibility/data/checkbox.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - CheckBox { - id: checkbox - objectName: "checkbox" - text: "CheckBox" - } +CheckBox { + text: "CheckBox" } diff --git a/tests/auto/accessibility/data/checkdelegate.qml b/tests/auto/accessibility/data/checkdelegate.qml new file mode 100644 index 00000000..0a1a4a4f --- /dev/null +++ b/tests/auto/accessibility/data/checkdelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +CheckDelegate { + text: "CheckDelegate" +} diff --git a/tests/auto/accessibility/data/combobox.qml b/tests/auto/accessibility/data/combobox.qml new file mode 100644 index 00000000..42e4d47b --- /dev/null +++ b/tests/auto/accessibility/data/combobox.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +ComboBox { + model: ["ComboBox"] +} diff --git a/tests/auto/accessibility/data/container.qml b/tests/auto/accessibility/data/container.qml new file mode 100644 index 00000000..806ebe78 --- /dev/null +++ b/tests/auto/accessibility/data/container.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Container { } diff --git a/tests/auto/accessibility/data/control.qml b/tests/auto/accessibility/data/control.qml index ceaba509..4831a6c6 100644 --- a/tests/auto/accessibility/data/control.qml +++ b/tests/auto/accessibility/data/control.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Control { - id: control - objectName: "control" - } -} +Control { } diff --git a/tests/auto/accessibility/data/dayofweekrow-2.qml b/tests/auto/accessibility/data/dayofweekrow-2.qml index 26569836..265f975a 100644 --- a/tests/auto/accessibility/data/dayofweekrow-2.qml +++ b/tests/auto/accessibility/data/dayofweekrow-2.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - DayOfWeekRow { - id: dayofweekrow - objectName: "dayofweekrow" - } -} +DayOfWeekRow { } diff --git a/tests/auto/accessibility/data/dayofweekrow.qml b/tests/auto/accessibility/data/dayofweekrow.qml index c799aba1..a3ab92dd 100644 --- a/tests/auto/accessibility/data/dayofweekrow.qml +++ b/tests/auto/accessibility/data/dayofweekrow.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - DayOfWeekRow { - id: dayofweekrow - objectName: "dayofweekrow" - Accessible.name: "DayOfWeekRow" - } +DayOfWeekRow { + Accessible.name: "DayOfWeekRow" } diff --git a/tests/auto/accessibility/data/dial.qml b/tests/auto/accessibility/data/dial.qml index 6b2333b1..39b85550 100644 --- a/tests/auto/accessibility/data/dial.qml +++ b/tests/auto/accessibility/data/dial.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Dial { - id: dial - objectName: "dial" - } -} +Dial { } diff --git a/tests/auto/accessibility/data/drawer.qml b/tests/auto/accessibility/data/drawer.qml new file mode 100644 index 00000000..12652164 --- /dev/null +++ b/tests/auto/accessibility/data/drawer.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Drawer { } diff --git a/tests/auto/accessibility/data/frame.qml b/tests/auto/accessibility/data/frame.qml new file mode 100644 index 00000000..6fcbab23 --- /dev/null +++ b/tests/auto/accessibility/data/frame.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Frame { } diff --git a/tests/auto/accessibility/data/groupbox.qml b/tests/auto/accessibility/data/groupbox.qml new file mode 100644 index 00000000..c48b4847 --- /dev/null +++ b/tests/auto/accessibility/data/groupbox.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +GroupBox { + title: "GroupBox" +} diff --git a/tests/auto/accessibility/data/itemdelegate.qml b/tests/auto/accessibility/data/itemdelegate.qml new file mode 100644 index 00000000..9b647315 --- /dev/null +++ b/tests/auto/accessibility/data/itemdelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +ItemDelegate { + text: "ItemDelegate" +} diff --git a/tests/auto/accessibility/data/label.qml b/tests/auto/accessibility/data/label.qml index 409898d4..bb87a4e9 100644 --- a/tests/auto/accessibility/data/label.qml +++ b/tests/auto/accessibility/data/label.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Label { - id: label - objectName: "label" - text: "Label" - } +Label { + text: "Label" } diff --git a/tests/auto/accessibility/data/menu.qml b/tests/auto/accessibility/data/menu.qml index bb777064..def3020b 100644 --- a/tests/auto/accessibility/data/menu.qml +++ b/tests/auto/accessibility/data/menu.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Menu { - id: menu - objectName: "menu" - } -} +Menu { } diff --git a/tests/auto/accessibility/data/menuitem.qml b/tests/auto/accessibility/data/menuitem.qml new file mode 100644 index 00000000..70c2ff33 --- /dev/null +++ b/tests/auto/accessibility/data/menuitem.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +MenuItem { + text: "MenuItem" +} diff --git a/tests/auto/accessibility/data/monthgrid-2.qml b/tests/auto/accessibility/data/monthgrid-2.qml index 76af6646..603a208b 100644 --- a/tests/auto/accessibility/data/monthgrid-2.qml +++ b/tests/auto/accessibility/data/monthgrid-2.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - MonthGrid { - id: monthgrid - objectName: "monthgrid" - title: "MonthGrid" - } +MonthGrid { + title: "MonthGrid" } diff --git a/tests/auto/accessibility/data/monthgrid.qml b/tests/auto/accessibility/data/monthgrid.qml index 7c8d6451..92a45f0f 100644 --- a/tests/auto/accessibility/data/monthgrid.qml +++ b/tests/auto/accessibility/data/monthgrid.qml @@ -1,14 +1,7 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - MonthGrid { - id: monthgrid - objectName: "monthgrid" - title: "MonthGrid" - Accessible.name: title - } +MonthGrid { + title: "MonthGrid" + Accessible.name: title } diff --git a/tests/auto/accessibility/data/page.qml b/tests/auto/accessibility/data/page.qml new file mode 100644 index 00000000..59139855 --- /dev/null +++ b/tests/auto/accessibility/data/page.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Page { + title: "Page" +} diff --git a/tests/auto/accessibility/data/pageindicator.qml b/tests/auto/accessibility/data/pageindicator.qml index b42d3f9e..bb69a27a 100644 --- a/tests/auto/accessibility/data/pageindicator.qml +++ b/tests/auto/accessibility/data/pageindicator.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - PageIndicator { - id: pageindicator - objectName: "pageindicator" - } -} +PageIndicator { } diff --git a/tests/auto/accessibility/data/pane.qml b/tests/auto/accessibility/data/pane.qml new file mode 100644 index 00000000..1de210ec --- /dev/null +++ b/tests/auto/accessibility/data/pane.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Pane { } diff --git a/tests/auto/accessibility/data/popup.qml b/tests/auto/accessibility/data/popup.qml index 70fe2e5f..05e968e5 100644 --- a/tests/auto/accessibility/data/popup.qml +++ b/tests/auto/accessibility/data/popup.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Popup { - id: popup - objectName: "popup" - } -} +Popup { } diff --git a/tests/auto/accessibility/data/progressbar.qml b/tests/auto/accessibility/data/progressbar.qml index 283db003..5e9b11f1 100644 --- a/tests/auto/accessibility/data/progressbar.qml +++ b/tests/auto/accessibility/data/progressbar.qml @@ -1,15 +1,8 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - ProgressBar { - id: progressbar - objectName: "progressbar" - from: 0 - to: 100 - value: 50 - } +ProgressBar { + from: 0 + to: 100 + value: 50 } diff --git a/tests/auto/accessibility/data/radiobutton.qml b/tests/auto/accessibility/data/radiobutton.qml index 1883fff8..58bdf225 100644 --- a/tests/auto/accessibility/data/radiobutton.qml +++ b/tests/auto/accessibility/data/radiobutton.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - RadioButton { - id: radiobutton - objectName: "radiobutton" - text: "RadioButton" - } +RadioButton { + text: "RadioButton" } diff --git a/tests/auto/accessibility/data/radiodelegate.qml b/tests/auto/accessibility/data/radiodelegate.qml new file mode 100644 index 00000000..93ccafde --- /dev/null +++ b/tests/auto/accessibility/data/radiodelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +RadioDelegate { + text: "RadioDelegate" +} diff --git a/tests/auto/accessibility/data/rangeslider.qml b/tests/auto/accessibility/data/rangeslider.qml index ce3dc872..45b1d4ae 100644 --- a/tests/auto/accessibility/data/rangeslider.qml +++ b/tests/auto/accessibility/data/rangeslider.qml @@ -1,18 +1,11 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - RangeSlider { - id: rangeSlider - objectName: "rangeslider" - from: 0 - to: 100 - first.value: 25 - second.value: 75 - stepSize: 1 - orientation: "Horizontal" - } +RangeSlider { + from: 0 + to: 100 + first.value: 25 + second.value: 75 + stepSize: 1 + orientation: Qt.Horizontal } diff --git a/tests/auto/accessibility/data/scrollbar.qml b/tests/auto/accessibility/data/scrollbar.qml index 2e360422..f0598b4b 100644 --- a/tests/auto/accessibility/data/scrollbar.qml +++ b/tests/auto/accessibility/data/scrollbar.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - ScrollBar { - id: scrollbar - objectName: "scrollbar" - } -} +ScrollBar { } diff --git a/tests/auto/accessibility/data/scrollindicator.qml b/tests/auto/accessibility/data/scrollindicator.qml index e933dece..4cb81c4e 100644 --- a/tests/auto/accessibility/data/scrollindicator.qml +++ b/tests/auto/accessibility/data/scrollindicator.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - ScrollIndicator { - id: scrollindicator - objectName: "scrollindicator" - } -} +ScrollIndicator { } diff --git a/tests/auto/accessibility/data/slider.qml b/tests/auto/accessibility/data/slider.qml index 060bb66c..775ce7d0 100644 --- a/tests/auto/accessibility/data/slider.qml +++ b/tests/auto/accessibility/data/slider.qml @@ -1,17 +1,10 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Slider { - id: slider - objectName: "slider" - from: 0 - to: 100 - value: 50 - stepSize: 1 - orientation: "Horizontal" - } +Slider { + from: 0 + to: 100 + value: 50 + stepSize: 1 + orientation: Qt.Horizontal } diff --git a/tests/auto/accessibility/data/spinbox.qml b/tests/auto/accessibility/data/spinbox.qml index 9d29bccc..029cbc65 100644 --- a/tests/auto/accessibility/data/spinbox.qml +++ b/tests/auto/accessibility/data/spinbox.qml @@ -1,16 +1,9 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - SpinBox { - id: spinbox - objectName: "spinbox" - from: 0 - to: 100 - value: 50 - stepSize: 1 - } +SpinBox { + from: 0 + to: 100 + value: 50 + stepSize: 1 } diff --git a/tests/auto/accessibility/data/stackview.qml b/tests/auto/accessibility/data/stackview.qml new file mode 100644 index 00000000..cf3b76c2 --- /dev/null +++ b/tests/auto/accessibility/data/stackview.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +StackView { } diff --git a/tests/auto/accessibility/data/swipedelegate.qml b/tests/auto/accessibility/data/swipedelegate.qml new file mode 100644 index 00000000..a8acb5e0 --- /dev/null +++ b/tests/auto/accessibility/data/swipedelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +SwipeDelegate { + text: "SwipeDelegate" +} diff --git a/tests/auto/accessibility/data/swipeview.qml b/tests/auto/accessibility/data/swipeview.qml new file mode 100644 index 00000000..018ab772 --- /dev/null +++ b/tests/auto/accessibility/data/swipeview.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +SwipeView { } diff --git a/tests/auto/accessibility/data/switch.qml b/tests/auto/accessibility/data/switch.qml index 9913e3f1..8bb43893 100644 --- a/tests/auto/accessibility/data/switch.qml +++ b/tests/auto/accessibility/data/switch.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - Switch { - //id: switch - objectName: "switch" - text: "Switch" - } +Switch { + text: "Switch" } diff --git a/tests/auto/accessibility/data/switchdelegate.qml b/tests/auto/accessibility/data/switchdelegate.qml new file mode 100644 index 00000000..9f2324c0 --- /dev/null +++ b/tests/auto/accessibility/data/switchdelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +SwitchDelegate { + text: "SwitchDelegate" +} diff --git a/tests/auto/accessibility/data/tabbar.qml b/tests/auto/accessibility/data/tabbar.qml index 127c4e81..4b1f73a1 100644 --- a/tests/auto/accessibility/data/tabbar.qml +++ b/tests/auto/accessibility/data/tabbar.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - TabBar { - id: tabbar - objectName: "tabbar" - } -} +TabBar { } diff --git a/tests/auto/accessibility/data/tabbutton.qml b/tests/auto/accessibility/data/tabbutton.qml index cfb04ca2..6b979bc8 100644 --- a/tests/auto/accessibility/data/tabbutton.qml +++ b/tests/auto/accessibility/data/tabbutton.qml @@ -1,17 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - TabBar { - id: tabbar - objectName: "TabBar" - TabButton { - id: tabbutton - objectName: "tabbutton" - text: "TabButton" - } - } +TabButton { + text: "TabButton" } diff --git a/tests/auto/accessibility/data/textarea.qml b/tests/auto/accessibility/data/textarea.qml index 381c08bd..93b5b220 100644 --- a/tests/auto/accessibility/data/textarea.qml +++ b/tests/auto/accessibility/data/textarea.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - TextArea { - id: textarea - objectName: "textarea" - text: "TextArea" - } +TextArea { + text: "TextArea" } diff --git a/tests/auto/accessibility/data/textfield.qml b/tests/auto/accessibility/data/textfield.qml index 5db46d82..06ba1a58 100644 --- a/tests/auto/accessibility/data/textfield.qml +++ b/tests/auto/accessibility/data/textfield.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - TextField { - id: textfield - objectName: "textfield" - text: "TextField" - } +TextField { + text: "TextField" } diff --git a/tests/auto/accessibility/data/toolbar.qml b/tests/auto/accessibility/data/toolbar.qml index c0503aef..7b3ba07f 100644 --- a/tests/auto/accessibility/data/toolbar.qml +++ b/tests/auto/accessibility/data/toolbar.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - ToolBar { - id: toolbar - objectName: "toolbar" - } -} +ToolBar { } diff --git a/tests/auto/accessibility/data/toolbutton.qml b/tests/auto/accessibility/data/toolbutton.qml index 63aacddc..79f155ec 100644 --- a/tests/auto/accessibility/data/toolbutton.qml +++ b/tests/auto/accessibility/data/toolbutton.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import QtQuick.Controls 2.0 -Window { - visible: true - - ToolButton { - id: toolbutton - objectName: "toolbutton" - text: "ToolButton" - } +ToolButton { + text: "ToolButton" } diff --git a/tests/auto/accessibility/data/tooltip.qml b/tests/auto/accessibility/data/tooltip.qml new file mode 100644 index 00000000..1d1bae28 --- /dev/null +++ b/tests/auto/accessibility/data/tooltip.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +ToolTip { + text: "ToolTip" +} diff --git a/tests/auto/accessibility/data/tumbler.qml b/tests/auto/accessibility/data/tumbler.qml new file mode 100644 index 00000000..11c737d7 --- /dev/null +++ b/tests/auto/accessibility/data/tumbler.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +Tumbler { } diff --git a/tests/auto/accessibility/data/weeknumbercolumn-2.qml b/tests/auto/accessibility/data/weeknumbercolumn-2.qml index bc3b1739..7d682315 100644 --- a/tests/auto/accessibility/data/weeknumbercolumn-2.qml +++ b/tests/auto/accessibility/data/weeknumbercolumn-2.qml @@ -1,12 +1,4 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - WeekNumberColumn { - id: weeknumbercolumn - objectName: "weeknumbercolumn" - } -} +WeekNumberColumn { } diff --git a/tests/auto/accessibility/data/weeknumbercolumn.qml b/tests/auto/accessibility/data/weeknumbercolumn.qml index 7fadb5da..6b024872 100644 --- a/tests/auto/accessibility/data/weeknumbercolumn.qml +++ b/tests/auto/accessibility/data/weeknumbercolumn.qml @@ -1,13 +1,6 @@ import QtQuick 2.5 -import QtQuick.Window 2.2 import Qt.labs.calendar 1.0 -Window { - visible: true - - WeekNumberColumn { - id: weeknumbercolumn - objectName: "weeknumbercolumn" - Accessible.name: "WeekNumberColumn" - } +WeekNumberColumn { + Accessible.name: "WeekNumberColumn" } diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index e97e4702..99f6391e 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -34,27 +34,21 @@ ** ****************************************************************************/ -#include <qtest.h> -#include <QtTest/QSignalSpy> +#include <QtTest/qtest.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlcontext.h> -#include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> #include <QtQuickTemplates2/private/qquickpopup_p.h> #include "../shared/util.h" -#include "../shared/visualtestutil.h" #ifndef QT_NO_ACCESSIBILITY #include <QtQuick/private/qquickaccessibleattached_p.h> #endif -using namespace QQuickVisualTestUtil; - class tst_accessibility : public QQmlDataTest { Q_OBJECT -public: private slots: void a11y_data(); @@ -70,35 +64,47 @@ void tst_accessibility::a11y_data() QTest::addColumn<int>("role"); QTest::addColumn<QString>("text"); + QTest::newRow("AbstractButton") << "abstractbutton" << 0x0000002B << "AbstractButton"; //QAccessible::Button QTest::newRow("BusyIndicator") << "busyindicator" << 0x00000027 << ""; //QAccessible::Indicator QTest::newRow("Button") << "button" << 0x0000002B << "Button"; //QAccessible::Button QTest::newRow("CheckBox") << "checkbox" << 0x0000002C << "CheckBox"; //QAccessible::CheckBox - // Frame - // GroupBox + QTest::newRow("CheckDelegate") << "checkdelegate" << 0x0000002C << "CheckDelegate"; //QAccessible::CheckBox + QTest::newRow("ComboBox") << "combobox" << 0x0000002E << "ComboBox"; //QAccessible::ComboBox + QTest::newRow("Container") << "container" << 0x00000000 << ""; //QAccessible::NoRole + QTest::newRow("Control") << "control" << 0x00000000 << ""; //QAccessible::NoRole + QTest::newRow("Dial") << "dial" << 0x00000031 << ""; //QAccessible::Dial + QTest::newRow("Drawer") << "drawer" << 0x00000012 << ""; //QAccessible::Dialog + QTest::newRow("Frame") << "frame" << 0x00000013 << ""; //QAccessible::Border + QTest::newRow("GroupBox") << "groupbox" << 0x00000014 << "GroupBox"; //QAccessible::Grouping + QTest::newRow("ItemDelegate") << "itemdelegate" << 0x00000022 << "ItemDelegate"; //QAccessible::ListItem QTest::newRow("Label") << "label" << 0x00000029 << "Label"; //QAccessible::StaticText QTest::newRow("Menu") << "menu" << 0x0000000B << ""; //QAccessible::PopupMenu + QTest::newRow("MenuItem") << "menuitem" << 0x0000000C << "MenuItem"; //QAccessible::MenuItem + QTest::newRow("Page") << "page" << 0x00000025 << "Page"; //QAccessible::PageTab QTest::newRow("PageIndicator") << "pageindicator" << 0x00000027 << ""; //QAccessible::Indicator - QTest::newRow("Popup") << "popup" << 0x00000080 << ""; //QAccessible::LayeredPane + QTest::newRow("Pane") << "pane" << 0x00000010 << ""; //QAccessible::Pane + QTest::newRow("Popup") << "popup" << 0x00000012 << ""; //QAccessible::Dialog QTest::newRow("ProgressBar") << "progressbar" << 0x00000030 << ""; //QAccessible::ProgressBar QTest::newRow("RadioButton") << "radiobutton" << 0x0000002D << "RadioButton"; //QAccessible::RadioButton + QTest::newRow("RadioDelegate") << "radiodelegate" << 0x0000002D << "RadioDelegate"; //QAccessible::RadioButton QTest::newRow("RangeSlider") << "rangeslider" << 0x00000033 << ""; //QAccessible::Slider QTest::newRow("ScrollBar") << "scrollbar" << 0x00000003 << ""; //QAccessible::ScrollBar QTest::newRow("ScrollIndicator") << "scrollindicator" << 0x00000027 << ""; //QAccessible::Indicator QTest::newRow("Slider") << "slider" << 0x00000033 << ""; //QAccessible::Slider QTest::newRow("SpinBox") << "spinbox" << 0x00000034 << ""; //QAccessible::SpinBox - // StackView + QTest::newRow("StackView") << "stackview" << 0x00000080 << ""; //QAccessible::LayeredPane + QTest::newRow("SwipeDelegate") << "swipedelegate" << 0x00000022 << "SwipeDelegate"; //QAccessible::ListItem + QTest::newRow("SwipeView") << "swipeview" << 0x0000003C << ""; //QAccessible::Pane QTest::newRow("Switch") << "switch" << 0x0000002B << "Switch"; //QAccessible::Button + QTest::newRow("SwitchDelegate") << "switchdelegate" << 0x00000022 << "SwitchDelegate"; //QAccessible::ListItem QTest::newRow("TabBar") << "tabbar" << 0x0000003C << ""; //QAccessible::PageTabList QTest::newRow("TabButton") << "tabbutton" << 0x00000025 << "TabButton"; //QAccessible::PageTab QTest::newRow("TextArea") << "textarea" << 0x0000002A << ""; //QAccessible::Accessible.EditableText QTest::newRow("TextField") << "textfield" << 0x0000002A << ""; //QAccessible::Accessible.EditableText QTest::newRow("ToolBar") << "toolbar" << 0x00000016 << ""; //QAccessible::ToolBar QTest::newRow("ToolButton") << "toolbutton" << 0x0000002B << "ToolButton"; //QAccessible::Button - - QTest::newRow("Dial") << "dial" << 0x00000031 << ""; //QAccessible::Dial - // Drawer - // SwipeView - // Tumbler + QTest::newRow("ToolTip") << "tooltip" << 0x0000000D << "ToolTip"; //QAccessible::ToolTip + QTest::newRow("Tumbler") << "tumbler" << 0x00000000 << ""; //QAccessible::NoRole (TODO) QTest::newRow("DayOfWeekRow") << "dayofweekrow" << 0x0 << "DayOfWeekRow"; //QAccessible::NoRole QTest::newRow("MonthGrid") << "monthgrid" << 0x0 << "MonthGrid"; //QAccessible::NoRole @@ -119,7 +125,6 @@ void tst_accessibility::a11y() QFETCH(int, role); QFETCH(QString, text); - QQmlComponent component(&engine); QString fn = name; #ifdef QT_NO_ACCESSIBILITY if (name == QLatin1Literal("dayofweekrow") @@ -127,20 +132,16 @@ void tst_accessibility::a11y() || name == QLatin1Literal("weeknumbercolumn")) fn += QLatin1Literal("-2"); #endif + + QQmlComponent component(&engine); component.loadUrl(testFileUrl(fn + ".qml")); - QObject* created = component.create(); - QVERIFY2(created, qPrintable(component.errorString())); - QScopedPointer<QObject> cleanup(created); - QVERIFY(!cleanup.isNull()); - QQuickWindow* window = qobject_cast<QQuickWindow*>(created); - QVERIFY(window); - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); - QQuickItem *item = findItem<QQuickItem>(window->contentItem(), name); + QQuickItem *item = qobject_cast<QQuickItem *>(object.data()); if (!item) { - QQuickPopup *popup = window->contentItem()->findChild<QQuickPopup *>(name); + QQuickPopup *popup = qobject_cast<QQuickPopup *>(object.data()); if (popup) item = popup->popupItem(); } diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index f8717a88..9038f1d6 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -52,16 +52,21 @@ TestCase { Component { id: button - Button { - id: control + Button { } + } - property SignalSequenceSpy spy: SignalSequenceSpy { - target: control - signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "downChanged", "checkedChanged"] - } + Component { + id: signalSequenceSpy + SignalSequenceSpy { + signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "downChanged", "checkedChanged"] } } + Component { + id: signalSpy + SignalSpy { } + } + function test_text() { var control = button.createObject(testCase) verify(control) @@ -79,52 +84,54 @@ TestCase { var control = button.createObject(testCase) verify(control) + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + // click - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], ["downChanged", { "down": false }], "released", "clicked"] mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // release outside - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], ["downChanged", { "down": false }]] mouseMove(control, control.width * 2, control.height * 2, 0, Qt.LeftButton) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["canceled", { "pressed": false }]] + sequenceSpy.expectedSequence = [["canceled", { "pressed": false }]] mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // right button - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.pressed, false) mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // double click - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], @@ -140,7 +147,7 @@ TestCase { "released", "clicked"] mouseDoubleClickSequence(control, control.width / 2, control.height / 2, Qt.LeftButton) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -152,8 +159,10 @@ TestCase { control.forceActiveFocus() verify(control.activeFocus) + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + // click - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], @@ -161,15 +170,15 @@ TestCase { "released", "clicked"] keyClick(Qt.Key_Space) - verify(control.spy.success) + verify(sequenceSpy.success) // no change - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] var keys = [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab] for (var i = 0; i < keys.length; ++i) { - control.spy.reset() + sequenceSpy.reset() keyClick(keys[i]) - verify(control.spy.success) + verify(sequenceSpy.success) } control.destroy() @@ -179,8 +188,6 @@ TestCase { return "actual event:" + JSON.stringify(actual) + ", expected event:" + JSON.stringify(expected) } - SignalSpy { id: clickSpy; signalName: "clicked" } - function test_autoRepeat() { var control = button.createObject(testCase) verify(control) @@ -192,50 +199,77 @@ TestCase { control.forceActiveFocus() verify(control.activeFocus) - clickSpy.target = control + var clickSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) verify(clickSpy.valid) + var pressSpy = signalSpy.createObject(control, {target: control, signalName: "pressed"}) + verify(pressSpy.valid) + var releaseSpy = signalSpy.createObject(control, {target: control, signalName: "released"}) + verify(releaseSpy.valid) - var repeatCount = 2 - var repeatSequence = [["pressedChanged", { "pressed": true }], - ["downChanged", { "down": true }], - "pressed", - "released", - "clicked", - "pressed", - "released", - "clicked", - "pressed"] - - // auto-repeat a couple of mouse clicks - control.spy.expectedSequence = repeatSequence + // auto-repeat mouse click mousePress(control) compare(control.pressed, true) - tryCompare(clickSpy, "count", repeatCount) - verify(control.spy.success) - - control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], - ["downChanged", { "down": false }], - "released", - "clicked"] + clickSpy.wait() + clickSpy.wait() + compare(pressSpy.count, clickSpy.count + 1) + compare(releaseSpy.count, clickSpy.count) mouseRelease(control) compare(control.pressed, false) - verify(control.spy.success) + compare(clickSpy.count, pressSpy.count) + compare(releaseSpy.count, pressSpy.count) - // auto-repeat a couple of key clicks clickSpy.clear() - control.spy.expectedSequence = repeatSequence + pressSpy.clear() + releaseSpy.clear() + + // auto-repeat key click keyPress(Qt.Key_Space) compare(control.pressed, true) - tryCompare(clickSpy, "count", repeatCount) - verify(control.spy.success) - - control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], - ["downChanged", { "down": false }], - "released", - "clicked"] + clickSpy.wait() + clickSpy.wait() + compare(pressSpy.count, clickSpy.count + 1) + compare(releaseSpy.count, clickSpy.count) keyRelease(Qt.Key_Space) compare(control.pressed, false) - verify(control.spy.success) + compare(clickSpy.count, pressSpy.count) + compare(releaseSpy.count, pressSpy.count) + + clickSpy.clear() + pressSpy.clear() + releaseSpy.clear() + + mousePress(control) + compare(control.pressed, true) + clickSpy.wait() + compare(pressSpy.count, clickSpy.count + 1) + compare(releaseSpy.count, clickSpy.count) + + // move inside during repeat -> continue repeat + mouseMove(control, control.width / 4, control.height / 4) + clickSpy.wait() + compare(pressSpy.count, clickSpy.count + 1) + compare(releaseSpy.count, clickSpy.count) + + clickSpy.clear() + pressSpy.clear() + releaseSpy.clear() + + // move outside during repeat -> stop repeat + mouseMove(control, -1, -1) + // NOTE: The following wait() is NOT a reliable way to test that the + // auto-repeat timer is not running, but there's no way dig into the + // private APIs from QML. If this test ever fails in the future, it + // indicates that the auto-repeat timer logic is broken. + wait(125) + compare(clickSpy.count, 0) + compare(pressSpy.count, 0) + compare(releaseSpy.count, 0) + + mouseRelease(control, -1, -1) + compare(control.pressed, false) + compare(clickSpy.count, 0) + compare(pressSpy.count, 0) + compare(releaseSpy.count, 0) control.destroy() } @@ -253,7 +287,9 @@ TestCase { verify(control.hasOwnProperty("checkable")) verify(!control.checkable) - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], @@ -262,9 +298,9 @@ TestCase { "clicked"] mouseClick(control) verify(!control.checked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], @@ -275,9 +311,9 @@ TestCase { control.checkable = true mouseClick(control) verify(control.checked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], @@ -287,7 +323,7 @@ TestCase { "clicked"] mouseClick(control) verify(!control.checked) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml index bb0ffe00..754e4f0b 100644 --- a/tests/auto/controls/data/tst_buttongroup.qml +++ b/tests/auto/controls/data/tst_buttongroup.qml @@ -55,30 +55,9 @@ TestCase { ButtonGroup { } } - SignalSpy { - id: checkedButtonSpy - signalName: "checkedButtonChanged" - } - - SignalSpy { - id: buttonsSpy - signalName: "buttonsChanged" - } - - function init() { - verify(!checkedButtonSpy.target) - compare(checkedButtonSpy.count, 0) - - verify(!buttonsSpy.target) - compare(buttonsSpy.count, 0) - } - - function cleanup() { - checkedButtonSpy.target = null - checkedButtonSpy.clear() - - buttonsSpy.target = null - buttonsSpy.clear() + Component { + id: signalSpy + SignalSpy { } } function test_null() { @@ -105,7 +84,7 @@ TestCase { var group = buttonGroup.createObject(testCase) verify(group) - checkedButtonSpy.target = group + var checkedButtonSpy = signalSpy.createObject(testCase, {target: group, signalName: "checkedButtonChanged"}) verify(checkedButtonSpy.valid) verify(!group.checkedButton) @@ -176,7 +155,7 @@ TestCase { var group = buttonGroup.createObject(testCase) verify(group) - buttonsSpy.target = group + var buttonsSpy = signalSpy.createObject(testCase, {target: group, signalName: "buttonsChanged"}) verify(buttonsSpy.valid) compare(group.buttons.length, 0) @@ -301,7 +280,7 @@ TestCase { var group = buttonGroup.createObject(testCase) verify(group) - buttonsSpy.target = group + var buttonsSpy = signalSpy.createObject(testCase, {target: group, signalName: "buttonsChanged"}) verify(buttonsSpy.valid) var button1 = button.createObject(testCase, {objectName: "button1", checked: true}) diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml index 7969b589..044b0006 100644 --- a/tests/auto/controls/data/tst_checkbox.qml +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -52,13 +52,13 @@ TestCase { Component { id: checkBox - CheckBox { - id: control + CheckBox { } + } - property SignalSequenceSpy spy: SignalSequenceSpy { - target: control - signals: ["pressed", "released", "canceled", "clicked", "pressedChanged", "checkedChanged", "checkStateChanged"] - } + Component { + id: signalSequenceSpy + SignalSequenceSpy { + signals: ["pressed", "released", "canceled", "clicked", "pressedChanged", "checkedChanged", "checkStateChanged"] } } @@ -79,24 +79,26 @@ TestCase { var control = checkBox.createObject(testCase) verify(control) - control.spy.expectedSequence = [] + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["checkStateChanged", { "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["checkStateChanged", { "checked": true, "checkState": Qt.Checked }], ["checkedChanged", { "checked": true, "checkState": Qt.Checked }]] control.checked = true compare(control.checked, true) compare(control.checkState, Qt.Checked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["checkStateChanged", { "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["checkStateChanged", { "checked": false, "checkState": Qt.Unchecked }], ["checkedChanged", { "checked": false, "checkState": Qt.Unchecked }]] control.checked = false compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -105,24 +107,26 @@ TestCase { var control = checkBox.createObject(testCase) verify(control) - control.spy.expectedSequence = [] + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["checkStateChanged", { "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["checkStateChanged", { "checked": true, "checkState": Qt.Checked }], ["checkedChanged", { "checked": true, "checkState": Qt.Checked }]] control.checkState = Qt.Checked compare(control.checked, true) compare(control.checkState, Qt.Checked) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["checkStateChanged", { "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["checkStateChanged", { "checked": false, "checkState": Qt.Unchecked }], ["checkedChanged", { "checked": false, "checkState": Qt.Unchecked }]] control.checkState = Qt.Unchecked compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -131,14 +135,16 @@ TestCase { var control = checkBox.createObject(testCase) verify(control) + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + // check - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], "released", @@ -147,15 +153,15 @@ TestCase { compare(control.checked, true) compare(control.checkState, Qt.Checked) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // uncheck - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], "released", @@ -164,34 +170,34 @@ TestCase { compare(control.checked, false) compare(control.checkState, Qt.Unchecked) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // release outside - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]] + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]] mouseMove(control, control.width * 2, control.height * 2, 0, Qt.LeftButton) compare(control.pressed, false) - verify(control.spy.success) - control.spy.expectedSequence = [["canceled", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]] + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["canceled", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]] mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // right button - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.pressed, false) mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -200,13 +206,15 @@ TestCase { var control = checkBox.createObject(testCase) verify(control) - control.spy.expectedSequence = [] + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] control.forceActiveFocus() verify(control.activeFocus) - verify(control.spy.success) + verify(sequenceSpy.success) // check - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], @@ -216,10 +224,10 @@ TestCase { keyClick(Qt.Key_Space) compare(control.checked, true) compare(control.checkState, Qt.Checked) - verify(control.spy.success) + verify(sequenceSpy.success) // uncheck - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], "pressed", ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], @@ -229,16 +237,16 @@ TestCase { keyClick(Qt.Key_Space) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) // no change - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] var keys = [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab] for (var i = 0; i < keys.length; ++i) { - control.spy.reset() + sequenceSpy.reset() keyClick(keys[i]) compare(control.checked, false) - verify(control.spy.success) + verify(sequenceSpy.success) } control.destroy() @@ -323,7 +331,9 @@ TestCase { function test_tristate() { var control = checkBox.createObject(testCase) - control.spy.expectedSequence = [] + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] control.forceActiveFocus() verify(control.activeFocus) @@ -331,16 +341,16 @@ TestCase { compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - control.spy.expectedSequence = [["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], + sequenceSpy.expectedSequence = [["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }]] control.checkState = Qt.PartiallyChecked compare(control.tristate, true) compare(control.checked, true) compare(control.checkState, Qt.PartiallyChecked) - verify(control.spy.success) + verify(sequenceSpy.success) // key: partial -> checked - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], @@ -349,10 +359,10 @@ TestCase { keyClick(Qt.Key_Space) compare(control.checked, true) compare(control.checkState, Qt.Checked) - verify(control.spy.success) + verify(sequenceSpy.success) // key: checked -> unchecked - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], "pressed", ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], @@ -362,10 +372,10 @@ TestCase { keyClick(Qt.Key_Space) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) // key: unchecked -> partial - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], @@ -375,10 +385,10 @@ TestCase { keyClick(Qt.Key_Space) compare(control.checked, true) compare(control.checkState, Qt.PartiallyChecked) - verify(control.spy.success) + verify(sequenceSpy.success) // mouse: partial -> checked - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], @@ -387,10 +397,10 @@ TestCase { mouseClick(control) compare(control.checked, true) compare(control.checkState, Qt.Checked) - verify(control.spy.success) + verify(sequenceSpy.success) // mouse: checked -> unchecked - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }], "pressed", ["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }], ["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], @@ -400,10 +410,10 @@ TestCase { mouseClick(control) compare(control.checked, false) compare(control.checkState, Qt.Unchecked) - verify(control.spy.success) + verify(sequenceSpy.success) // mouse: unchecked -> partial - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }], "pressed", ["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }], ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }], @@ -413,7 +423,7 @@ TestCase { mouseClick(control) compare(control.checked, true) compare(control.checkState, Qt.PartiallyChecked) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 479b1002..607de2e8 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -51,16 +51,6 @@ TestCase { when: windowShown name: "ComboBox" - SignalSpy { - id: activatedSpy - signalName: "activated" - } - - SignalSpy { - id: highlightedSpy - signalName: "highlighted" - } - Component { id: signalSpy SignalSpy { } @@ -80,22 +70,6 @@ TestCase { } } - function init() { - verify(!activatedSpy.target) - compare(activatedSpy.count, 0) - - verify(!highlightedSpy.target) - compare(highlightedSpy.count, 0) - } - - function cleanup() { - activatedSpy.target = null - activatedSpy.clear() - - highlightedSpy.target = null - highlightedSpy.clear() - } - function test_defaults() { var control = comboBox.createObject(testCase) verify(control) @@ -332,10 +306,10 @@ TestCase { var control = comboBox.createObject(testCase, {model: 3}) verify(control) - activatedSpy.target = control + var activatedSpy = signalSpy.createObject(control, {target: control, signalName: "activated"}) verify(activatedSpy.valid) - highlightedSpy.target = control + var highlightedSpy = signalSpy.createObject(control, {target: control, signalName: "highlighted"}) verify(highlightedSpy.valid) waitForRendering(control) @@ -457,7 +431,7 @@ TestCase { control.destroy() } - function test_keys_data() { + function test_keys_space_enter_escape_data() { return [ { tag: "space-space", key1: Qt.Key_Space, key2: Qt.Key_Space, showPopup: true, showPress: true, hidePopup: true, hidePress: true }, { tag: "space-enter", key1: Qt.Key_Space, key2: Qt.Key_Enter, showPopup: true, showPress: true, hidePopup: true, hidePress: true }, @@ -470,7 +444,7 @@ TestCase { ] } - function test_keys(data) { + function test_keys_space_enter_escape(data) { var control = comboBox.createObject(testCase, {model: 3}) verify(control) @@ -493,7 +467,6 @@ TestCase { // hide popup keyPress(data.key2) compare(control.pressed, data.hidePress) - compare(control.popup.visible, data.showPopup) keyRelease(data.key2) compare(control.pressed, false) tryCompare(control.popup, "visible", !data.hidePopup) @@ -501,6 +474,162 @@ TestCase { control.destroy() } + function test_keys_home_end() { + var control = comboBox.createObject(testCase, {model: 5}) + verify(control) + + control.forceActiveFocus() + verify(control.activeFocus) + compare(control.currentIndex, 0) + compare(control.highlightedIndex, -1) + + var activatedCount = 0 + var activatedSpy = signalSpy.createObject(control, {target: control, signalName: "activated"}) + verify(activatedSpy.valid) + + var highlightedCount = 0 + var highlightedSpy = signalSpy.createObject(control, {target: control, signalName: "highlighted"}) + verify(highlightedSpy.valid) + + var currentIndexCount = 0 + var currentIndexSpy = signalSpy.createObject(control, {target: control, signalName: "currentIndexChanged"}) + verify(currentIndexSpy.valid) + + var highlightedIndexCount = 0 + var highlightedIndexSpy = signalSpy.createObject(control, {target: control, signalName: "highlightedIndexChanged"}) + verify(highlightedIndexSpy.valid) + + // end (popup closed) + keyClick(Qt.Key_End) + compare(control.currentIndex, 4) + compare(currentIndexSpy.count, ++currentIndexCount) + + compare(control.highlightedIndex, -1) + compare(highlightedIndexSpy.count, highlightedIndexCount) + + compare(activatedSpy.count, ++activatedCount) + compare(activatedSpy.signalArguments[activatedCount-1][0], 4) + + compare(highlightedSpy.count, highlightedCount) + + // repeat (no changes/signals) + keyClick(Qt.Key_End) + compare(currentIndexSpy.count, currentIndexCount) + compare(highlightedIndexSpy.count, highlightedIndexCount) + compare(activatedSpy.count, activatedCount) + compare(highlightedSpy.count, highlightedCount) + + // home (popup closed) + keyClick(Qt.Key_Home) + compare(control.currentIndex, 0) + compare(currentIndexSpy.count, ++currentIndexCount) + + compare(control.highlightedIndex, -1) + compare(highlightedIndexSpy.count, highlightedIndexCount) + + compare(activatedSpy.count, ++activatedCount) + compare(activatedSpy.signalArguments[activatedCount-1][0], 0) + + compare(highlightedSpy.count, highlightedCount) + + // repeat (no changes/signals) + keyClick(Qt.Key_Home) + compare(currentIndexSpy.count, currentIndexCount) + compare(highlightedIndexSpy.count, highlightedIndexCount) + compare(activatedSpy.count, activatedCount) + compare(highlightedSpy.count, highlightedCount) + + control.popup.open() + compare(control.highlightedIndex, 0) + compare(highlightedIndexSpy.count, ++highlightedIndexCount) + compare(highlightedSpy.count, highlightedCount) + + // end (popup open) + keyClick(Qt.Key_End) + compare(control.currentIndex, 0) + compare(currentIndexSpy.count, currentIndexCount) + + compare(control.highlightedIndex, 4) + compare(highlightedIndexSpy.count, ++highlightedIndexCount) + + compare(activatedSpy.count, activatedCount) + + compare(highlightedSpy.count, ++highlightedCount) + compare(highlightedSpy.signalArguments[highlightedCount-1][0], 4) + + // repeat (no changes/signals) + keyClick(Qt.Key_End) + compare(currentIndexSpy.count, currentIndexCount) + compare(highlightedIndexSpy.count, highlightedIndexCount) + compare(activatedSpy.count, activatedCount) + compare(highlightedSpy.count, highlightedCount) + + // home (popup open) + keyClick(Qt.Key_Home) + compare(control.currentIndex, 0) + compare(currentIndexSpy.count, currentIndexCount) + + compare(control.highlightedIndex, 0) + compare(highlightedIndexSpy.count, ++highlightedIndexCount) + + compare(activatedSpy.count, activatedCount) + + compare(highlightedSpy.count, ++highlightedCount) + compare(highlightedSpy.signalArguments[highlightedCount-1][0], 0) + + // repeat (no changes/signals) + keyClick(Qt.Key_Home) + compare(currentIndexSpy.count, currentIndexCount) + compare(highlightedIndexSpy.count, highlightedIndexCount) + compare(activatedSpy.count, activatedCount) + compare(highlightedSpy.count, highlightedCount) + + control.destroy() + } + + function test_keySearch() { + var control = comboBox.createObject(testCase, {model: ["Banana", "Coco", "Coconut", "Apple", "Cocomuffin"]}) + verify(control) + + control.forceActiveFocus() + verify(control.activeFocus) + + compare(control.currentIndex, 0) + compare(control.currentText, "Banana") + + keyPress(Qt.Key_C) + compare(control.currentIndex, 1) + compare(control.currentText, "Coco") + + // no match + keyPress(Qt.Key_N) + compare(control.currentIndex, 1) + compare(control.currentText, "Coco") + + keyPress(Qt.Key_C) + compare(control.currentIndex, 2) + compare(control.currentText, "Coconut") + + keyPress(Qt.Key_C) + compare(control.currentIndex, 4) + compare(control.currentText, "Cocomuffin") + + // wrap + keyPress(Qt.Key_C) + compare(control.currentIndex, 1) + compare(control.currentText, "Coco") + + keyPress(Qt.Key_A) + compare(control.currentIndex, 3) + compare(control.currentText, "Apple") + + keyPress(Qt.Key_B) + compare(control.currentIndex, 0) + compare(control.currentText, "Banana") + + control.destroy() + } + function test_popup() { var control = comboBox.createObject(testCase, {model: 3}) verify(control) @@ -544,10 +673,10 @@ TestCase { var control = comboBox.createObject(testCase, {model: 3}) verify(control) - activatedSpy.target = control + var activatedSpy = signalSpy.createObject(control, {target: control, signalName: "activated"}) verify(activatedSpy.valid) - highlightedSpy.target = control + var highlightedSpy = signalSpy.createObject(control, {target: control, signalName: "highlighted"}) verify(highlightedSpy.valid) mouseClick(control) diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index 4b7a60dc..3018498e 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -71,21 +71,6 @@ TestCase { SignalSpy { } } - SignalSpy { - id: mirroredSpy - signalName: "mirroredChanged" - } - - SignalSpy { - id: availableWidthSpy - signalName: "availableWidthChanged" - } - - SignalSpy { - id: availableHeightSpy - signalName: "availableHeightChanged" - } - function test_padding() { var control = component.createObject(testCase) verify(control) @@ -150,10 +135,10 @@ TestCase { var control = component.createObject(testCase) verify(control) - availableWidthSpy.target = control - availableHeightSpy.target = control - + var availableWidthSpy = signalSpy.createObject(control, {target: control, signalName: "availableWidthChanged"}) verify(availableWidthSpy.valid) + + var availableHeightSpy = signalSpy.createObject(control, {target: control, signalName: "availableHeightChanged"}) verify(availableHeightSpy.valid) var availableWidthChanges = 0 @@ -222,7 +207,7 @@ TestCase { var control = component.createObject(testCase) verify(control) - mirroredSpy.target = control + var mirroredSpy = signalSpy.createObject(control, {target: control, signalName: "mirroredChanged"}) verify(mirroredSpy.valid) control.locale = Qt.locale("en_US") @@ -862,8 +847,15 @@ TestCase { compare(control.mirroredspy_5.count, 1) } - function test_hover() { - var control = component.createObject(testCase, {width: 100, height: 100}) + function test_hover_data() { + return [ + { tag: "normal", target: component, pressed: false }, + { tag: "pressed", target: button, pressed: true } + ] + } + + function test_hover(data) { + var control = data.target.createObject(testCase, {width: 100, height: 100}) verify(control) compare(control.hovered, false) @@ -877,9 +869,19 @@ TestCase { mouseMove(control, control.width / 2, control.height / 2) compare(control.hovered, true) + if (data.pressed) { + mousePress(control, control.width / 2, control.height / 2) + compare(control.hovered, true) + } + mouseMove(control, -10, -10) compare(control.hovered, false) + if (data.pressed) { + mouseRelease(control, -10, control.height / 2) + compare(control.hovered, false) + } + mouseMove(control, control.width / 2, control.height / 2) compare(control.hovered, true) diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 8d8f94b7..0ca8ce57 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -72,65 +72,28 @@ TestCase { Rectangle { } } - SignalSpy { - id: availableWidthSpy - signalName: "availableWidthChanged" - } - - SignalSpy { - id: availableHeightSpy - signalName: "availableHeightChanged" - } - - SignalSpy { - id: paddingSpy - signalName: "paddingChanged" - } - - SignalSpy { - id: topPaddingSpy - signalName: "topPaddingChanged" - } - - SignalSpy { - id: leftPaddingSpy - signalName: "leftPaddingChanged" - } - - SignalSpy { - id: rightPaddingSpy - signalName: "rightPaddingChanged" - } - - SignalSpy { - id: bottomPaddingSpy - signalName: "bottomPaddingChanged" - } - - SignalSpy { - id: xSpy - signalName: "xChanged" - } - - SignalSpy { - id: ySpy - signalName: "yChanged" + Component { + id: signalSpy + SignalSpy { } } function test_padding() { var control = popupTemplate.createObject(testCase) verify(control) - paddingSpy.target = control - topPaddingSpy.target = control - leftPaddingSpy.target = control - rightPaddingSpy.target = control - bottomPaddingSpy.target = control - + var paddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "paddingChanged"}) verify(paddingSpy.valid) + + var topPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "topPaddingChanged"}) verify(topPaddingSpy.valid) + + var leftPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "leftPaddingChanged"}) verify(leftPaddingSpy.valid) + + var rightPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "rightPaddingChanged"}) verify(rightPaddingSpy.valid) + + var bottomPaddingSpy = signalSpy.createObject(testCase, {target: control, signalName: "bottomPaddingChanged"}) verify(bottomPaddingSpy.valid) var paddingChanges = 0 @@ -229,10 +192,10 @@ TestCase { var control = popupTemplate.createObject(testCase) verify(control) - availableWidthSpy.target = control - availableHeightSpy.target = control - + var availableWidthSpy = signalSpy.createObject(testCase, {target: control, signalName: "availableWidthChanged"}) verify(availableWidthSpy.valid) + + var availableHeightSpy = signalSpy.createObject(testCase, {target: control, signalName: "availableHeightChanged"}) verify(availableHeightSpy.valid) var availableWidthChanges = 0 @@ -302,10 +265,10 @@ TestCase { verify(control) verify(control.visible) - xSpy.target = control - ySpy.target = control - + var xSpy = signalSpy.createObject(testCase, {target: control, signalName: "xChanged"}) verify(xSpy.valid) + + var ySpy = signalSpy.createObject(testCase, {target: control, signalName: "yChanged"}) verify(ySpy.valid) // moving outside margins does not trigger change notifiers @@ -1266,4 +1229,35 @@ TestCase { control.destroy() } + + Component { + id: xyBindingLoop + ApplicationWindow { + id: window + width: 360 + height: 360 + visible: true + property alias popup: popup + + Popup { + id: popup + visible: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + Label { + text: "Content" + anchors.fill: parent + } + } + } + } + + function test_xyBindingLoop() { + var window = xyBindingLoop.createObject(testCase) + var control = window.popup + waitForRendering(control.contentItem) + compare(control.x, (control.parent.width - control.width) / 2) + compare(control.y, (control.parent.height - control.height) / 2) + window.destroy() + } } diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml index bd3850c8..e86b862e 100644 --- a/tests/auto/controls/data/tst_radiobutton.qml +++ b/tests/auto/controls/data/tst_radiobutton.qml @@ -52,13 +52,13 @@ TestCase { Component { id: radioButton - RadioButton { - id: control + RadioButton { } + } - property SignalSequenceSpy spy: SignalSequenceSpy { - target: control - signals: ["pressed", "released", "canceled", "clicked", "pressedChanged", "checkedChanged"] - } + Component { + id: signalSequenceSpy + SignalSequenceSpy { + signals: ["pressed", "released", "canceled", "clicked", "pressedChanged", "checkedChanged"] } } @@ -79,19 +79,21 @@ TestCase { var control = radioButton.createObject(testCase) verify(control) - control.spy.expectedSequence = [] // No change expected + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] // No change expected compare(control.checked, false) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.expectedSequence = ["checkedChanged"] + sequenceSpy.expectedSequence = ["checkedChanged"] control.checked = true compare(control.checked, true) - verify(control.spy.success) + verify(sequenceSpy.success) - control.spy.reset() + sequenceSpy.reset() control.checked = false compare(control.checked, false) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -100,59 +102,61 @@ TestCase { var control = radioButton.createObject(testCase) verify(control) + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + // check - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false }], + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false }], ["checkedChanged", { "pressed": false, "checked": true }], "released", "clicked"] mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.checked, true) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // attempt uncheck - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true }], + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true }], "released", "clicked"] mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.checked, true) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // release outside - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) - verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true }]] + verify(sequenceSpy.success) + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true }]] mouseMove(control, control.width * 2, control.height * 2, 0, Qt.LeftButton) compare(control.pressed, false) - control.spy.expectedSequence = [["canceled", { "pressed": false, "checked": true }]] + sequenceSpy.expectedSequence = [["canceled", { "pressed": false, "checked": true }]] mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton) compare(control.checked, true) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) // right button - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) compare(control.checked, true) compare(control.pressed, false) - verify(control.spy.success) + verify(sequenceSpy.success) control.destroy() } @@ -161,13 +165,15 @@ TestCase { var control = radioButton.createObject(testCase) verify(control) - control.spy.expectedSequence = [] + var sequenceSpy = signalSequenceSpy.createObject(control, {target: control}) + + sequenceSpy.expectedSequence = [] control.forceActiveFocus() verify(control.activeFocus) - verify(control.spy.success) + verify(sequenceSpy.success) // check - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }], "pressed", ["pressedChanged", { "pressed": false, "checked": false }], ["checkedChanged", { "pressed": false, "checked": true }], @@ -175,26 +181,26 @@ TestCase { "clicked"] keyClick(Qt.Key_Space) compare(control.checked, true) - verify(control.spy.success) + verify(sequenceSpy.success) // attempt uncheck - control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], + sequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true }], "pressed", ["pressedChanged", { "pressed": false, "checked": true }], "released", "clicked"] keyClick(Qt.Key_Space) compare(control.checked, true) - verify(control.spy.success) + verify(sequenceSpy.success) // no change - control.spy.expectedSequence = [] + sequenceSpy.expectedSequence = [] var keys = [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab] for (var i = 0; i < keys.length; ++i) { - control.spy.reset() + sequenceSpy.reset() keyClick(keys[i]) compare(control.checked, true) - verify(control.spy.success) + verify(sequenceSpy.success) } control.destroy() diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 581a079c..3167be0b 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -50,14 +50,9 @@ TestCase { when: windowShown name: "RangeSlider" - SignalSpy { - id: firstPressedSpy - signalName: "pressedChanged" - } - - SignalSpy { - id: secondPressedSpy - signalName: "pressedChanged" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -84,21 +79,6 @@ TestCase { } } - function init() { - verify(!firstPressedSpy.target) - compare(firstPressedSpy.count, 0) - - verify(!secondPressedSpy.target) - compare(secondPressedSpy.count, 0) - } - - function cleanup() { - firstPressedSpy.target = null - firstPressedSpy.clear() - secondPressedSpy.target = null - secondPressedSpy.clear() - } - function test_defaults() { var control = sliderComponent.createObject(testCase) verify(control) @@ -303,10 +283,10 @@ TestCase { var control = sliderComponent.createObject(testCase, { orientation: data.orientation }) verify(control) - firstPressedSpy.target = control.first + var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) verify(firstPressedSpy.valid) - secondPressedSpy.target = control.second + var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) verify(secondPressedSpy.valid) mousePress(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton) @@ -473,7 +453,7 @@ TestCase { var pressedCount = 0 - firstPressedSpy.target = control.first + var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) verify(firstPressedSpy.valid) control.first.handle.forceActiveFocus() @@ -511,7 +491,7 @@ TestCase { control.stepSize = 0.25 pressedCount = 0; - secondPressedSpy.target = control.second + var secondPressedSpy = signalSpy.createObject(control, {target: control.second, signalName: "pressedChanged"}) verify(secondPressedSpy.valid) control.second.handle.forceActiveFocus() @@ -553,7 +533,7 @@ TestCase { var control = sliderComponent.createObject(testCase, { leftPadding: 10, rightPadding: 20 }) verify(control) - firstPressedSpy.target = control.first + var firstPressedSpy = signalSpy.createObject(control, {target: control.first, signalName: "pressedChanged"}) verify(firstPressedSpy.valid) mousePress(control, control.first.handle.x, control.first.handle.y, Qt.LeftButton) diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 7dc60d97..7c83cca9 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -50,9 +50,9 @@ TestCase { when: windowShown name: "ScrollBar" - SignalSpy{ - id: pressedSpy - signalName: "pressedChanged" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -72,16 +72,6 @@ TestCase { } } - function init() { - verify(!pressedSpy.target) - compare(pressedSpy.count, 0) - } - - function cleanup() { - pressedSpy.target = null - pressedSpy.clear() - } - function test_attach() { var container = flickable.createObject(testCase) verify(container) @@ -151,6 +141,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } @@ -165,7 +171,7 @@ TestCase { var control = scrollBar.createObject(testCase, data.properties) verify(control) - pressedSpy.target = control + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) verify(pressedSpy.valid) mousePress(control, 0, 0, Qt.LeftButton) @@ -211,6 +217,31 @@ TestCase { control.destroy() } + function test_increase_decrease_data() { + return [ + { tag: "increase:active", increase: true, active: true }, + { tag: "decrease:active", increase: false, active: true }, + { tag: "increase:inactive", increase: true, active: false }, + { tag: "decrease:inactive", increase: false, active: false } + ] + } + + function test_increase_decrease(data) { + var control = scrollBar.createObject(testCase, {position: 0.5, active: data.active}) + verify(control) + + if (data.increase) { + control.increase() + compare(control.position, 0.6) + } else { + control.decrease() + compare(control.position, 0.4) + } + compare(control.active, data.active) + + control.destroy() + } + function test_stepSize_data() { return [ { tag: "0.0", stepSize: 0.0 }, diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index 90d9287a..f5e57e2d 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -136,6 +136,22 @@ TestCase { compare(horizontal.size, container.visibleArea.widthRatio) compare(horizontal.position, container.visibleArea.xPosition) + var oldY = vertical.y + var oldHeight = vertical.height + vertical.parent = testCase + vertical.y -= 10 + container.height += 10 + compare(vertical.y, oldY - 10) + compare(vertical.height, oldHeight) + + var oldX = horizontal.x + var oldWidth = horizontal.width + horizontal.parent = testCase + horizontal.x -= 10 + container.width += 10 + compare(horizontal.x, oldX - 10) + compare(horizontal.width, oldWidth) + container.destroy() } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index bec4d236..4a698076 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -50,9 +50,9 @@ TestCase { when: windowShown name: "Slider" - SignalSpy{ - id: pressedSpy - signalName: "pressedChanged" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -60,16 +60,6 @@ TestCase { Slider { } } - function init() { - verify(!pressedSpy.target) - compare(pressedSpy.count, 0) - } - - function cleanup() { - pressedSpy.target = null - pressedSpy.clear() - } - function test_defaults() { var control = slider.createObject(testCase) verify(control) @@ -232,7 +222,7 @@ TestCase { var control = slider.createObject(testCase, {orientation: data.orientation}) verify(control) - pressedSpy.target = control + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) verify(pressedSpy.valid) mousePress(control, 0, 0, Qt.LeftButton) @@ -308,7 +298,7 @@ TestCase { var pressedCount = 0 - pressedSpy.target = control + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) verify(pressedSpy.valid) control.forceActiveFocus() @@ -380,7 +370,7 @@ TestCase { var control = slider.createObject(testCase, {leftPadding: 10, rightPadding: 20}) verify(control) - pressedSpy.target = control + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) verify(pressedSpy.valid) mousePress(control, 0, 0, Qt.LeftButton) diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index b370a05f..f2d8d3ef 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -50,14 +50,9 @@ TestCase { when: windowShown name: "SpinBox" - SignalSpy{ - id: upPressedSpy - signalName: "pressedChanged" - } - - SignalSpy{ - id: downPressedSpy - signalName: "pressedChanged" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -65,20 +60,6 @@ TestCase { SpinBox { } } - function init() { - verify(!upPressedSpy.target) - compare(upPressedSpy.count, 0) - verify(!downPressedSpy.target) - compare(downPressedSpy.count, 0) - } - - function cleanup() { - upPressedSpy.target = null - upPressedSpy.clear() - downPressedSpy.target = null - downPressedSpy.clear() - } - function test_defaults() { var control = spinBox.createObject(testCase) verify(control) @@ -190,9 +171,12 @@ TestCase { var control = spinBox.createObject(testCase, {stepSize: 50}) verify(control) - upPressedSpy.target = control.up + var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"}) verify(upPressedSpy.valid) + var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"}) + verify(downPressedSpy.valid) + mousePress(control.up.indicator) compare(upPressedSpy.count, 1) compare(control.up.pressed, true) @@ -225,9 +209,6 @@ TestCase { compare(control.down.pressed, false) compare(control.value, control.to) - downPressedSpy.target = control.down - verify(downPressedSpy.valid) - control.value = 50; mousePress(control.down.indicator) compare(downPressedSpy.count, 1) @@ -271,10 +252,10 @@ TestCase { var upPressedCount = 0 var downPressedCount = 0 - upPressedSpy.target = control.up + var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"}) verify(upPressedSpy.valid) - downPressedSpy.target = control.down + var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"}) verify(downPressedSpy.valid) control.forceActiveFocus() @@ -510,4 +491,66 @@ TestCase { control.destroy() } + + function test_autoRepeat() { + var control = spinBox.createObject(testCase) + verify(control) + + compare(control.value, 0) + + var valueSpy = signalSpy.createObject(control, {target: control, signalName: "valueChanged"}) + verify(valueSpy.valid) + + var countBefore = 0 + + // repeat up + mousePress(control.up.indicator) + verify(control.up.pressed) + compare(valueSpy.count, 0) + valueSpy.wait() + valueSpy.wait() + countBefore = valueSpy.count + mouseRelease(control.up.indicator) + verify(!control.up.pressed) + compare(valueSpy.count, countBefore) + + valueSpy.clear() + + // repeat down + mousePress(control.down.indicator) + verify(control.down.pressed) + compare(valueSpy.count, 0) + valueSpy.wait() + valueSpy.wait() + countBefore = valueSpy.count + mouseRelease(control.down.indicator) + verify(!control.down.pressed) + compare(valueSpy.count, countBefore) + + mousePress(control.up.indicator) + verify(control.up.pressed) + valueSpy.wait() + + // move inside during repeat -> continue repeat (QTBUG-57085) + mouseMove(control.up.indicator, control.up.indicator.width / 4, control.up.indicator.height / 4) + verify(control.up.pressed) + valueSpy.wait() + + valueSpy.clear() + + // move outside during repeat -> stop repeat + mouseMove(control.up.indicator, -1, -1) + verify(!control.up.pressed) + // NOTE: The following wait() is NOT a reliable way to test that the + // auto-repeat timer is not running, but there's no way dig into the + // private APIs from QML. If this test ever fails in the future, it + // indicates that the auto-repeat timer logic is broken. + wait(125) + compare(valueSpy.count, 0) + + mouseRelease(control.up.indicator, -1, -1) + verify(!control.up.pressed) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index ab6ce332..28a22306 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -59,6 +59,11 @@ TestCase { StackView { } } + Component { + id: signalSpy + SignalSpy { } + } + function test_initialItem() { var control1 = stackView.createObject(testCase) verify(control1) @@ -87,18 +92,13 @@ TestCase { control.destroy() } - SignalSpy { - id: busySpy - signalName: "busyChanged" - } - function test_busy() { var control = stackView.createObject(testCase) verify(control) compare(control.busy, false) var busyCount = 0 - busySpy.target = control + var busySpy = signalSpy.createObject(control, {target: control, signalName: "busyChanged"}) verify(busySpy.valid) control.push(component) diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 16cfea14..0404fd86 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -304,7 +304,7 @@ TestCase { var control = swipeDelegateComponent.createObject(testCase); verify(control); - var overDragDistance = dragDistance * 1.1; + var overDragDistance = Math.round(dragDistance * 1.1); mouseSignalSequenceSpy.target = control; mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; @@ -361,7 +361,7 @@ TestCase { verify(control.swipe.rightItem); verify(!control.swipe.rightItem.visible); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width / 2, control.height / 2); verify(!control.pressed); compare(control.swipe.position, 1.0); @@ -388,7 +388,8 @@ TestCase { verify(!control.swipe.complete); compare(control.swipe.position, 1.0 - overDragDistance / control.width); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + // Since we went over the drag distance, we should expect canceled() to be emitted. + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width * 0.4, control.height / 2); verify(!control.pressed); compare(control.swipe.position, 1.0); @@ -409,7 +410,7 @@ TestCase { verify(!control.swipe.complete); compare(control.swipe.position, 0.4); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width * -0.1, control.height / 2); verify(!control.pressed); compare(control.swipe.position, 0.0); @@ -433,7 +434,7 @@ TestCase { var control = swipeDelegateComponent.createObject(testCase); verify(control); - var distance = dragDistance * 1.1; + var distance = Math.round(dragDistance * 1.1); if (distance >= control.width / 2) skip("This test requires a startDragDistance that is less than half the width of the control"); @@ -826,7 +827,7 @@ TestCase { control.swipe.left = smallLeftComponent; // Ensure that the position is scaled to the width of the currently visible delegate. - var overDragDistance = dragDistance * 1.1; + var overDragDistance = Math.round(dragDistance * 1.1); mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); mouseMove(control, control.width / 2 + overDragDistance, control.height / 2, Qt.LeftButton); verify(control.swipe.leftItem); @@ -885,7 +886,7 @@ TestCase { mousePress(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); compare(leftVisibleSpy.count, 0); compare(rightVisibleSpy.count, 0); - var newX = control.swipe.leftItem.width - dragDistance * 1.1; + var newX = control.swipe.leftItem.width - Math.round(dragDistance * 1.1); mouseMove(control, newX, control.height / 2, Qt.LeftButton, Qt.LeftButton); compare(leftVisibleSpy.count, 0); compare(rightVisibleSpy.count, 0); @@ -1033,4 +1034,43 @@ TestCase { control.destroy(); } + + function test_releaseOutside_data() { + return [ + { tag: "no delegates", component: emptySwipeDelegateComponent }, + { tag: "delegates", component: swipeDelegateComponent }, + ]; + } + + function test_releaseOutside(data) { + var control = data.component.createObject(testCase); + verify(control); + + // Press and then release below the control. + mouseSignalSequenceSpy.target = control; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed", ["pressedChanged", { "pressed": false }]]; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2, control.height + 10, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + + mouseSignalSequenceSpy.expectedSequence = ["canceled"]; + mouseRelease(control, control.width / 2, control.height + 10, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + + // Press and then release to the right of the control. + var hasDelegates = control.swipe.left || control.swipe.right || control.swipe.behind; + mouseSignalSequenceSpy.target = control; + mouseSignalSequenceSpy.expectedSequence = hasDelegates + ? [["pressedChanged", { "pressed": true }], "pressed"] + : [["pressedChanged", { "pressed": true }], "pressed", ["pressedChanged", { "pressed": false }]]; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width + 10, control.height / 2, Qt.LeftButton); + if (hasDelegates) + verify(control.swipe.position > 0); + verify(mouseSignalSequenceSpy.success); + + mouseSignalSequenceSpy.expectedSequence = hasDelegates ? [["pressedChanged", { "pressed": false }], "canceled"] : ["canceled"]; + mouseRelease(control, control.width + 10, control.height / 2, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + } } diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index df22bb09..3afcdf16 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -60,20 +60,16 @@ TestCase { Text { } } - SignalSpy { - id: currentItemChangedSpy - signalName: "currentItemChanged" - } - - function cleanup() { - currentItemChangedSpy.clear() - currentItemChangedSpy.target = null + Component { + id: signalSpy + SignalSpy { } } function test_current() { var control = swipeView.createObject(testCase) - currentItemChangedSpy.target = control + var currentItemChangedSpy = signalSpy.createObject(testCase, {target: control, signalName: "currentItemChanged"}) + verify(currentItemChangedSpy.valid) compare(control.count, 0) compare(control.currentIndex, -1) @@ -146,7 +142,8 @@ TestCase { control.currentIndexChanged.connect(verifyCurrentIndexCountDiff) control.countChanged.connect(verifyCurrentIndexCountDiff) - currentItemChangedSpy.target = control; + var currentItemChangedSpy = signalSpy.createObject(testCase, {target: control, signalName: "currentItemChanged"}) + verify(currentItemChangedSpy.valid) compare(control.count, 0) compare(control.currentIndex, -1) diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml index eee3205f..9268f765 100644 --- a/tests/auto/controls/data/tst_tabbar.qml +++ b/tests/auto/controls/data/tst_tabbar.qml @@ -85,19 +85,9 @@ TestCase { } } - SignalSpy { - id: contentChildrenSpy - signalName: "contentChildrenChanged" - } - - function init() { - verify(!contentChildrenSpy.target) - compare(contentChildrenSpy.count, 0) - } - - function cleanup() { - contentChildrenSpy.target = null - contentChildrenSpy.clear() + Component { + id: signalSpy + SignalSpy { } } function test_defaults() { @@ -176,7 +166,7 @@ TestCase { control.currentIndexChanged.connect(verifyCurrentIndexCountDiff) control.countChanged.connect(verifyCurrentIndexCountDiff) - contentChildrenSpy.target = control + var contentChildrenSpy = signalSpy.createObject(testCase, {target: control, signalName: "contentChildrenChanged"}) verify(contentChildrenSpy.valid) compare(control.count, 0) @@ -293,7 +283,7 @@ TestCase { return true } - contentChildrenSpy.target = control + var contentChildrenSpy = signalSpy.createObject(testCase, {target: control, signalName: "contentChildrenChanged"}) verify(contentChildrenSpy.valid) verify(compareObjectNames(control.contentData, ["object", "button1", "timer", "button2", ""])) diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml index 1417c8e2..73431ca6 100644 --- a/tests/auto/controls/data/tst_toolbutton.qml +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -50,19 +50,9 @@ TestCase { when: windowShown name: "ToolButton" - SignalSpy { - id: pressedSpy - signalName: "pressedChanged" - } - - SignalSpy { - id: downSpy - signalName: "downChanged" - } - - SignalSpy { - id: clickedSpy - signalName: "clicked" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -70,20 +60,6 @@ TestCase { ToolButton { } } - function init() { - verify(!pressedSpy.target) - verify(!clickedSpy.target) - compare(pressedSpy.count, 0) - compare(clickedSpy.count, 0) - } - - function cleanup() { - pressedSpy.target = null - clickedSpy.target = null - pressedSpy.clear() - clickedSpy.clear() - } - function test_text() { var control = toolButton.createObject(testCase) verify(control) @@ -101,11 +77,13 @@ TestCase { var control = toolButton.createObject(testCase) verify(control) - pressedSpy.target = control - downSpy.target = control - clickedSpy.target = control + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"}) verify(pressedSpy.valid) + + var downSpy = signalSpy.createObject(control, {target: control, signalName: "downChanged"}) verify(downSpy.valid) + + var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) verify(clickedSpy.valid) // check @@ -170,7 +148,7 @@ TestCase { var control = toolButton.createObject(testCase) verify(control) - clickedSpy.target = control + var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) verify(clickedSpy.valid) control.forceActiveFocus() diff --git a/tests/auto/drawer/BLACKLIST b/tests/auto/drawer/BLACKLIST deleted file mode 100644 index 1b06b49c..00000000 --- a/tests/auto/drawer/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[touch] -windows diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 80385421..ab652466 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -380,7 +380,7 @@ void tst_Drawer::reposition() window->setWidth(window->width() + 100); QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QCOMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); drawer->close(); QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); @@ -714,6 +714,11 @@ void tst_Drawer::touch() QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer*>(); QVERIFY(drawer); + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); + QVERIFY(drawerOpenedSpy.isValid()); + QVERIFY(drawerClosedSpy.isValid()); + struct TouchDeviceDeleter { static inline void cleanup(QTouchDevice *device) @@ -732,7 +737,8 @@ void tst_Drawer::touch() QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100)); QTRY_COMPARE(drawer->position(), 0.5); QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100)); - QTRY_COMPARE(drawer->position(), 1.0); + QVERIFY(drawerOpenedSpy.wait()); + QCOMPARE(drawer->position(), 1.0); // drag to close QTest::touchEvent(window, device.data()).press(0, QPoint(300, 100)); @@ -744,7 +750,8 @@ void tst_Drawer::touch() QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100)); QTRY_COMPARE(drawer->position(), 0.5); QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100)); - QTRY_COMPARE(drawer->position(), 0.0); + QVERIFY(drawerClosedSpy.wait()); + QCOMPARE(drawer->position(), 0.0); } void tst_Drawer::grabber() diff --git a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml index f4a51afb..5c655cab 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml @@ -51,7 +51,7 @@ Window { BusyIndicator { id: busyIndicator - running: false + running: true anchors.centerIn: parent } } diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml b/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml index ef53721d..3195c1c9 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-checkbox.qml @@ -48,8 +48,8 @@ Window { height: column.implicitHeight visible: true - property alias second: second - property alias third: third + property alias control2: control2 + property alias control3: control3 ColumnLayout { id: column @@ -60,11 +60,11 @@ Window { text: qsTr("First") } CheckBox { - id: second + id: control2 text: qsTr("Second") } CheckBox { - id: third + id: control3 checked: true text: qsTr("Third") } diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml new file mode 100644 index 00000000..eddb71d5 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate-tristate.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.0 + +Window { + id: window + width: 170 + height: column.implicitHeight + visible: true + + property alias english: english + property alias norwegian: norwegian + + ColumnLayout { + id: column + anchors.fill: parent + + CheckDelegate { + text: qsTr("Languages") + checkState: english.checked && norwegian.checked + ? Qt.Checked : (english.checked || norwegian.checked) ? Qt.PartiallyChecked : Qt.Unchecked + tristate: true + Layout.fillWidth: true + } + CheckDelegate { + id: english + text: qsTr("English") + checked: true + leftPadding: indicator.width + 14 + Layout.fillWidth: true + } + CheckDelegate { + id: norwegian + text: qsTr("Norwegian") + checked: true + leftPadding: indicator.width + 14 + Layout.fillWidth: true + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-combobox.qml b/tests/manual/gifs/data/qtquickcontrols2-combobox.qml new file mode 100644 index 00000000..718ed166 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-combobox.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.0 + +Window { + width: 140 + height: 180 + visible: true + + property alias comboBox: comboBox + + ComboBox { + id: comboBox + model: ["First", "Second", "Third"] + y: 10 + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-drawer.qml b/tests/manual/gifs/data/qtquickcontrols2-drawer.qml new file mode 100644 index 00000000..49f2cf50 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-drawer.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.0 + +ApplicationWindow { + id: window + width: 300 + height: 300 + visible: true + + property alias drawer: drawer + + Drawer { + id: drawer + width: window.width * 0.66 + height: window.height + rightPadding: 0 + + Rectangle { + border.width: 1 + anchors.fill: parent + + Label { + text: "Drawer" + font.pixelSize: 32 + anchors.centerIn: parent + } + } + } + + Rectangle { + border.width: 1 + anchors.fill: parent + + Label { + text: "Content" + font.pixelSize: 32 + anchors.centerIn: parent + } + } + + Rectangle { + z: 1 + color: "black" + width: 1 + height: parent.height + parent: window.overlay + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml b/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml new file mode 100644 index 00000000..0785b279 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-progressbar-indeterminate.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +Window { + width: progressBar.implicitWidth + height: 64 + visible: true + + property alias progressBar: progressBar + + ProgressBar { + id: progressBar + indeterminate: true + anchors.centerIn: parent + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml b/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml new file mode 100644 index 00000000..13d5075d --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-progressbar.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +Window { + width: progressBar.implicitWidth + height: 64 + visible: true + + property alias progressBar: progressBar + + ProgressBar { + id: progressBar + value: 0.5 + anchors.centerIn: parent + + Timer { + running: true + interval: 500 + onTriggered: animation.start() + } + + NumberAnimation { + id: animation + target: progressBar + property: "value" + to: 1 + duration: 2000 + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml b/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml new file mode 100644 index 00000000..576668f3 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-radiobutton.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.0 + +Window { + width: column.implicitWidth + height: column.implicitHeight + visible: true + + property alias control1: control1 + property alias control2: control2 + property alias control3: control3 + + ColumnLayout { + id: column + anchors.centerIn: parent + + RadioButton { + id: control1 + text: qsTr("First") + checked: true + } + RadioButton { + id: control2 + text: qsTr("Second") + } + RadioButton { + id: control3 + text: qsTr("Third") + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml b/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml new file mode 100644 index 00000000..091e5250 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-scrollindicator.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +Window { + width: 100 + height: 120 + visible: true + color: "#eeeeee" + + ListView { + anchors.fill: parent + + ScrollIndicator.vertical: ScrollIndicator { + active: true + } + + model: 10 + delegate: Label { + text: qsTr("Item %1").arg(index + 1) + width: 100 + height: 40 + leftPadding: 10 + verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml b/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml new file mode 100644 index 00000000..aa2351fc --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-slider-snap.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +Window { + width: slider.implicitWidth + height: slider.implicitHeight + visible: true + + property alias slider: slider + + Slider { + id: slider + stepSize: 0.2 + anchors.centerIn: parent + + Rectangle { + anchors.fill: slider.handle + radius: width / 2 + color: slider.pressed ? "#aa666666" : "transparent" + } + + contentItem: Item { + Repeater { + id: repeater + model: 6 + + Rectangle { + x: ((slider.contentItem.width - slider.handle.width) * (index / (repeater.count - 1))) + - width / 2 + slider.handle.width / 2 + y: parent.height + width: 1 + height: 4 + color: "#888" + } + } + } + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-stackview-pop.qml b/tests/manual/gifs/data/qtquickcontrols2-stackview-pop.qml new file mode 100644 index 00000000..2b4d3ee3 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-stackview-pop.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 160 + height: 160 + visible: true + color: "#eeeeee" + + property int maxDepth: 3 + + function itemText(index) { + return String.fromCharCode(65 + index); + } + + Component { + id: labelComponent + + Label { + font.pixelSize: 60 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + StackView { + id: stackView + anchors.fill: parent + + Component.onCompleted: { + for (var i = 0; i < maxDepth; ++i) { + stackView.push(labelComponent, { text: itemText(i) }, StackView.Immediate); + } + } + } + + Label { + id: operationLabel + text: "pop()" + font.pixelSize: 16 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 10 + } + + Timer { + id: operationTimer + running: true + interval: 1500 + onTriggered: { + stackView.pop(); + hideOperationTimer.start(); + } + } + + Timer { + id: hideOperationTimer + interval: operationTimer.interval + onTriggered: operationLabel.visible = false + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-stackview-push.qml b/tests/manual/gifs/data/qtquickcontrols2-stackview-push.qml new file mode 100644 index 00000000..dd318f1d --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-stackview-push.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 160 + height: 160 + visible: true + color: "#eeeeee" + + property int itemIndex: 0 + property int maxDepth: 3 + + function itemText(index) { + return String.fromCharCode(65 + index); + } + + Component { + id: labelComponent + + Label { + font.pixelSize: 60 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + StackView { + id: stackView + anchors.fill: parent + } + + Label { + id: operationLabel + text: "push(" + itemText(Math.max(0, Math.min(maxDepth - 1, itemIndex - 1))) + ")" + font.pixelSize: 16 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 10 + } + + Timer { + id: operationTimer + running: true + interval: 1500 + repeat: stackView.depth < maxDepth - 1 + onRepeatChanged: if (!repeat) hideOperationTimer.start() + + onTriggered: stackView.push(labelComponent, { text: itemText(itemIndex++) }) + } + + Timer { + id: hideOperationTimer + interval: operationTimer.interval * 2 + onTriggered: operationLabel.visible = false + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-stackview-replace.qml b/tests/manual/gifs/data/qtquickcontrols2-stackview-replace.qml new file mode 100644 index 00000000..2586a81b --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-stackview-replace.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 160 + height: 160 + visible: true + color: "#eeeeee" + + property int maxDepth: 3 + + function itemText(index) { + return String.fromCharCode(65 + index); + } + + Component { + id: labelComponent + + Label { + font.pixelSize: 60 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + StackView { + id: stackView + anchors.fill: parent + + Component.onCompleted: { + for (var i = 0; i < maxDepth; ++i) { + stackView.push(labelComponent, { text: itemText(i) }, StackView.Immediate); + } + } + } + + Label { + id: operationLabel + text: "replace(D)" + font.pixelSize: 16 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 10 + } + + Timer { + id: operationTimer + running: true + interval: 1500 + onTriggered: { + stackView.replace(labelComponent, { text: "D" }); + hideOperationTimer.start(); + } + } + + Timer { + id: hideOperationTimer + interval: operationTimer.interval + onTriggered: operationLabel.visible = false + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-stackview-unwind.qml b/tests/manual/gifs/data/qtquickcontrols2-stackview-unwind.qml new file mode 100644 index 00000000..6fb6b2a8 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-stackview-unwind.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 160 + height: 160 + visible: true + color: "#eeeeee" + + property int maxDepth: 3 + + function itemText(index) { + return String.fromCharCode(65 + index); + } + + Component { + id: labelComponent + + Label { + font.pixelSize: 60 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } + + StackView { + id: stackView + anchors.fill: parent + + Component.onCompleted: { + for (var i = 0; i < maxDepth; ++i) { + stackView.push(labelComponent, { text: itemText(i) }, StackView.Immediate); + } + } + } + + Label { + id: operationLabel + text: "pop(null)" + font.pixelSize: 16 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 10 + } + + Timer { + id: operationTimer + running: true + interval: 1500 + onTriggered: { + stackView.pop(null); + hideOperationTimer.start(); + } + } + + Timer { + id: hideOperationTimer + interval: operationTimer.interval + onTriggered: operationLabel.visible = false + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipeview.qml b/tests/manual/gifs/data/qtquickcontrols2-swipeview.qml new file mode 100644 index 00000000..d721591a --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-swipeview.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.0 +import QtQuick.Controls 2.0 + +Window { + width: 300 + height: 300 + visible: true + + property alias swipeView: view + + Rectangle { + border.width: 1 + anchors.fill: parent + } + + SwipeView { + id: view + anchors.fill: parent + + Label { + text: "First\nPage" + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + + Label { + text: "Second\nPage" + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + + Label { + text: "Third\nPage" + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + } + } + + PageIndicator { + id: indicator + + count: view.count + currentIndex: view.currentIndex + + anchors.bottom: view.bottom + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index e6fa9d61..d3fb5f6d 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -51,6 +51,8 @@ private slots: void tumblerWrap(); void slider(); + void sliderSnap_data(); + void sliderSnap(); void rangeSlider(); void busyIndicator(); void switchGif(); @@ -58,6 +60,7 @@ private slots: void button(); void tabBar(); void menu(); + void swipeView(); void swipeDelegate_data(); void swipeDelegate(); void swipeDelegateBehind(); @@ -65,9 +68,18 @@ private slots: void delegates(); void dial_data(); void dial(); - void checkBox(); - void checkBoxTriState(); void scrollBar(); + void scrollIndicator(); + void progressBar_data(); + void progressBar(); + void triState_data(); + void triState(); + void checkables_data(); + void checkables(); + void comboBox(); + void stackView_data(); + void stackView(); + void drawer(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, @@ -98,8 +110,8 @@ void tst_Gifs::moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoi int yDifference = to.y() - from.y(); for (int movement = 0; movement < movements; ++movement) { QPoint pos = QPoint( - from.x() + curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference, - from.y() + curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference); + from.x() + qRound(curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference), + from.y() + qRound(curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference)); QTest::mouseMove(window, pos, movementDelay); } } @@ -234,6 +246,58 @@ void tst_Gifs::slider() gifRecorder.waitForFinish(); } +void tst_Gifs::sliderSnap_data() +{ + QTest::addColumn<QString>("gifBaseName"); + QTest::addColumn<int>("snapMode"); + QTest::newRow("NoSnap") << "qtquickcontrols2-slider-nosnap" << 0; + QTest::newRow("SnapAlways") << "qtquickcontrols2-slider-snapalways" << 1; + QTest::newRow("SnapOnRelease") << "qtquickcontrols2-slider-snaponrelease" << 2; +} + +void tst_Gifs::sliderSnap() +{ + QFETCH(QString, gifBaseName); + QFETCH(int, snapMode); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(8); + gifRecorder.setHighQuality(true); + gifRecorder.setQmlFileName("qtquickcontrols2-slider-snap.qml"); + gifRecorder.setOutputFileBaseName(gifBaseName); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *slider = window->property("slider").value<QQuickItem*>(); + QVERIFY(slider); + QVERIFY(slider->setProperty("snapMode", QVariant(snapMode))); + QCOMPARE(slider->property("snapMode").toInt(), snapMode); + QQuickItem *handle = slider->property("handle").value<QQuickItem*>(); + QVERIFY(handle); + + const QPoint startPos(slider->property("leftPadding").toReal(), slider->height() / 2); + const int trackWidth = slider->property("availableWidth").toReal(); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 200); + QPoint pos1 = startPos + QPoint(trackWidth * 0.3, 0); + moveSmoothly(window, startPos, pos1, pos1.x() - startPos.x(), QEasingCurve::OutQuint, 30); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos1, 0); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 400); + const QPoint pos2 = startPos + QPoint(trackWidth * 0.6, 0); + moveSmoothly(window, pos1, pos2, pos2.x() - pos1.x(), QEasingCurve::OutQuint, 30); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos2, 0); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos2, 400); + moveSmoothly(window, pos2, startPos, qAbs(startPos.x() - pos2.x()) / 2, QEasingCurve::OutQuint, 30); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos, 0); + + gifRecorder.waitForFinish(); +} + void tst_Gifs::rangeSlider() { GifRecorder gifRecorder; @@ -288,7 +352,7 @@ void tst_Gifs::busyIndicator() GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); - gifRecorder.setRecordingDuration(3); + gifRecorder.setRecordingDuration(6); gifRecorder.setHighQuality(true); gifRecorder.setQmlFileName("qtquickcontrols2-busyindicator.qml"); @@ -296,17 +360,17 @@ void tst_Gifs::busyIndicator() QQuickWindow *window = gifRecorder.window(); // Record nothing for a bit to make it smoother. - QTest::qWait(400); + QTest::qWait(800 * 2); QQuickItem *busyIndicator = window->property("busyIndicator").value<QQuickItem*>(); QVERIFY(busyIndicator); - busyIndicator->setProperty("running", true); + busyIndicator->setProperty("running", false); // 800 ms is the duration of one rotation animation cycle for BusyIndicator. QTest::qWait(800 * 2); - busyIndicator->setProperty("running", false); + busyIndicator->setProperty("running", true); gifRecorder.waitForFinish(); } @@ -418,6 +482,31 @@ void tst_Gifs::menu() gifRecorder.waitForFinish(); } +void tst_Gifs::swipeView() +{ + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(8); + gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols2-swipeview.qml")); + gifRecorder.setHighQuality(true); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *swipeView = window->property("swipeView").value<QQuickItem*>(); + QVERIFY(swipeView); + + QTest::qWait(1200); + swipeView->setProperty("currentIndex", 1); + QTest::qWait(2000); + swipeView->setProperty("currentIndex", 2); + QTest::qWait(2000); + swipeView->setProperty("currentIndex", 0); + + gifRecorder.waitForFinish(); +} + void tst_Gifs::swipeDelegate_data() { QTest::addColumn<QString>("qmlFileName"); @@ -610,41 +699,104 @@ void tst_Gifs::dial() gifRecorder.waitForFinish(); } -void tst_Gifs::checkBox() +void tst_Gifs::checkables_data() { + QTest::addColumn<QString>("name"); + QTest::addColumn<QVector<int> >("pressIndices"); + + QTest::newRow("checkbox") << "checkbox" << (QVector<int>() << 1 << 2 << 2 << 1); + QTest::newRow("radiobutton") << "radiobutton" << (QVector<int>() << 1 << 2 << 1 << 0); +} + +void tst_Gifs::checkables() +{ + QFETCH(QString, name); + QFETCH(QVector<int>, pressIndices); + GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); - gifRecorder.setRecordingDuration(5); - gifRecorder.setQmlFileName("qtquickcontrols2-checkbox.qml"); + gifRecorder.setRecordingDuration(6); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name)); gifRecorder.start(); QQuickWindow *window = gifRecorder.window(); - QQuickItem *second = window->property("second").value<QQuickItem*>(); - QVERIFY(second); - QQuickItem *third = window->property("third").value<QQuickItem*>(); - QVERIFY(third); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - second->mapToScene(QPointF(second->width() / 2, second->height() / 2)).toPoint(), 400); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - third->mapToScene(QPointF(third->width() / 2, third->height() / 2)).toPoint(), 800); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - third->mapToScene(QPointF(third->width() / 2, third->height() / 2)).toPoint(), 800); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - second->mapToScene(QPointF(second->width() / 2, second->height() / 2)).toPoint(), 800); + + for (int i = 0; i < pressIndices.size(); ++i) { + const int pressIndex = pressIndices.at(i); + const char *controlId = qPrintable(QString::fromLatin1("control%1").arg(pressIndex + 1)); + QQuickItem *control = window->property(controlId).value<QQuickItem*>(); + QVERIFY(control); + + const QPoint pos = control->mapToScene(QPointF(control->width() / 2, control->height() / 2)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos, 800); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, pos, 300); + } gifRecorder.waitForFinish(); } -void tst_Gifs::checkBoxTriState() +void tst_Gifs::comboBox() { GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); gifRecorder.setRecordingDuration(6); - gifRecorder.setQmlFileName("qtquickcontrols2-checkbox-tristate.qml"); + gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols2-combobox.qml")); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *comboBox = window->property("comboBox").value<QQuickItem*>(); + QVERIFY(comboBox); + + // Open the popup. + const QPoint center = comboBox->mapToScene( + QPoint(comboBox->width() / 2, comboBox->height() / 2)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, center, 800); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, center, 80); + + // Select the third item. + QObject *popup = comboBox->property("popup").value<QObject*>(); + QVERIFY(popup); + QQuickItem *popupContent = popup->property("contentItem").value<QQuickItem*>(); + QVERIFY(popupContent); + const QPoint lastItemPos = popupContent->mapToScene( + QPoint(popupContent->width() / 2, popupContent->height() * 0.8)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 600); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 200); + + // Open the popup. + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, center, 1500); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, center, 80); + + // Select the first item. + const QPoint firstItemPos = popupContent->mapToScene( + QPoint(popupContent->width() / 2, popupContent->height() * 0.2)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, firstItemPos, 600); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, firstItemPos, 200); + + gifRecorder.waitForFinish(); +} + +void tst_Gifs::triState_data() +{ + QTest::addColumn<QString>("name"); + + QTest::newRow("checkbox-tristate") << "checkbox-tristate"; + QTest::newRow("checkdelegate-tristate") << "checkdelegate-tristate"; +} + +void tst_Gifs::triState() +{ + QFETCH(QString, name); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(6); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name)); gifRecorder.start(); @@ -654,14 +806,21 @@ void tst_Gifs::checkBoxTriState() QQuickItem *norwegian = window->property("norwegian").value<QQuickItem*>(); QVERIFY(norwegian); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - english->mapToScene(QPointF(english->width() / 2, english->height() / 2)).toPoint(), 1000); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - norwegian->mapToScene(QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint(), 1000); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - norwegian->mapToScene(QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint(), 1000); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - english->mapToScene(QPointF(english->width() / 2, english->height() / 2)).toPoint(), 1000); + const QPoint englishCenter = english->mapToScene( + QPointF(english->width() / 2, english->height() / 2)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300); + + const QPoint norwegianCenter = norwegian->mapToScene( + QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300); gifRecorder.waitForFinish(); } @@ -699,6 +858,111 @@ void tst_Gifs::scrollBar() gifRecorder.waitForFinish(); } +void tst_Gifs::scrollIndicator() +{ + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(6); + gifRecorder.setQmlFileName("qtquickcontrols2-scrollindicator.qml"); + + gifRecorder.start(); + + // Flick in the center of the screen to show that there's a scroll indicator. + QQuickWindow *window = gifRecorder.window(); + const QPoint windowBottom = QPoint(0, window->height() - 1); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowBottom, 100); + QTest::mouseMove(window, windowBottom - QPoint(0, 10), 30); + QTest::mouseMove(window, windowBottom - QPoint(0, 30), 30); + QTest::mouseMove(window, windowBottom - QPoint(0, 60), 30); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowBottom - QPoint(0, 100), 30); + + // Scroll back down. + const QPoint windowTop = QPoint(0, 0); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowTop, 2000); + QTest::mouseMove(window, windowTop + QPoint(0, 10), 30); + QTest::mouseMove(window, windowTop + QPoint(0, 30), 30); + QTest::mouseMove(window, windowTop + QPoint(0, 60), 30); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowTop + QPoint(0, 100), 30); + + gifRecorder.waitForFinish(); +} + +void tst_Gifs::progressBar_data() +{ + QTest::addColumn<bool>("indeterminate"); + + QTest::newRow("indeterminate:false") << false; + QTest::newRow("indeterminate:true") << true; +} + +void tst_Gifs::progressBar() +{ + QFETCH(bool, indeterminate); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(4); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-progressbar%1").arg( + indeterminate ? QLatin1String("-indeterminate.qml") : QLatin1String(".qml"))); + + gifRecorder.start(); + gifRecorder.waitForFinish(); +} + +void tst_Gifs::stackView_data() +{ + QTest::addColumn<QString>("name"); + QTest::addColumn<int>("duration"); + + QTest::newRow("push") << "push" << 8; + QTest::newRow("pop") << "pop" << 6; + QTest::newRow("unwind") << "unwind" << 6; + QTest::newRow("replace") << "replace" << 6; +} + +void tst_Gifs::stackView() +{ + QFETCH(QString, name); + QFETCH(int, duration); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(duration); + gifRecorder.setHighQuality(true); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-stackview-%1.qml").arg(name)); + + gifRecorder.start(); + gifRecorder.waitForFinish(); +} + +void tst_Gifs::drawer() +{ + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(4); + gifRecorder.setHighQuality(true); + gifRecorder.setQmlFileName("qtquickcontrols2-drawer.qml"); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QObject *drawer = window->property("drawer").value<QObject*>(); + qreal width = drawer->property("width").toReal(); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1), 100); + moveSmoothly(window, QPoint(1, 1), QPoint(width, 1), width, QEasingCurve::InOutBack, 1); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(width, 1), 30); + + QTest::qWait(1000); + QMetaObject::invokeMethod(drawer, "close"); + + gifRecorder.waitForFinish(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" diff --git a/tests/manual/testbench/main.cpp b/tests/manual/testbench/main.cpp index a782b5fe..5a54dab3 100644 --- a/tests/manual/testbench/main.cpp +++ b/tests/manual/testbench/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // TODO: move style selection into app UI and use settings to save choices. // qputenv("QT_QUICK_CONTROLS_STYLE", "material"); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/testbench.qml"))); return app.exec(); } diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index 5f6483ac..9f4b1783 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -1,5 +1,5 @@ <RCC> <qresource prefix="/"> - <file>main.qml</file> + <file>testbench.qml</file> </qresource> </RCC> diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/testbench.qml index 2fdc52af..3e8b3d0f 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/testbench.qml @@ -625,14 +625,14 @@ ApplicationWindow { Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 } } Frame { Tumbler { model: 5 - implicitWidth: 100 + implicitWidth: 80 implicitHeight: 100 enabled: false } @@ -641,11 +641,147 @@ ApplicationWindow { RowLayout { Dial { + implicitWidth: 100 + implicitHeight: 100 } Dial { + implicitWidth: 100 + implicitHeight: 100 enabled: false } } + + ListModel { + id: checkableDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Checked"; check: true } + ListElement { label: "CH + PR"; check: true; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: CheckDelegate { + text: label + width: parent.width + down: press + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + ButtonGroup { + id: radioButtonGroup + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: RadioDelegate { + text: label + down: press + width: parent.width + checked: check + enabled: !disabled + ButtonGroup.group: radioButtonGroup + } + } + } + } + + Frame { + Column { + width: 200 + + Repeater { + model: checkableDelegateModel + delegate: SwitchDelegate { + text: label + width: parent.width + checked: check + down: press + enabled: !disabled + } + } + } + } + } + + ListModel { + id: regularDelegateModel + ListElement { label: "Normal" } + ListElement { label: "Pressed"; press: true } + ListElement { label: "Disabled"; disabled: true } + } + + RowLayout { + Frame { + Column { + width: 200 + + Repeater { + model: regularDelegateModel + delegate: ItemDelegate { + text: label + width: parent.width + down: press + enabled: !disabled + } + } + } + } + Frame { + Column { + id: listView + width: 200 + clip: true + + Repeater { + model: regularDelegateModel + delegate: SwipeDelegate { + id: swipeDelegate + text: label + width: parent.width + down: press + enabled: !disabled + + Component { + id: removeComponent + + Rectangle { + color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" + width: parent.width + height: parent.height + clip: true + + Label { + font.pixelSize: swipeDelegate.font.pixelSize + text: "Boop" + color: "white" + anchors.centerIn: parent + } + } + } + + swipe.left: removeComponent + swipe.right: removeComponent + } + } + } + } + } } } } |