diff options
Diffstat (limited to 'tests')
156 files changed, 4060 insertions, 355 deletions
diff --git a/tests/auto/accessibility/data/busyindicator.qml b/tests/auto/accessibility/data/busyindicator.qml index 4bde9634..6806d64b 100644 --- a/tests/auto/accessibility/data/busyindicator.qml +++ b/tests/auto/accessibility/data/busyindicator.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/button.qml b/tests/auto/accessibility/data/button.qml index 75925185..100da3d4 100644 --- a/tests/auto/accessibility/data/button.qml +++ b/tests/auto/accessibility/data/button.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/checkbox.qml b/tests/auto/accessibility/data/checkbox.qml index 9700663d..fcd4628c 100644 --- a/tests/auto/accessibility/data/checkbox.qml +++ b/tests/auto/accessibility/data/checkbox.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/control.qml b/tests/auto/accessibility/data/control.qml index ceaba509..d177e7e3 100644 --- a/tests/auto/accessibility/data/control.qml +++ b/tests/auto/accessibility/data/control.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/dial.qml b/tests/auto/accessibility/data/dial.qml index 6b2333b1..4725d557 100644 --- a/tests/auto/accessibility/data/dial.qml +++ b/tests/auto/accessibility/data/dial.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/label.qml b/tests/auto/accessibility/data/label.qml index 409898d4..4904bb41 100644 --- a/tests/auto/accessibility/data/label.qml +++ b/tests/auto/accessibility/data/label.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/menu.qml b/tests/auto/accessibility/data/menu.qml index bb777064..589f4aaf 100644 --- a/tests/auto/accessibility/data/menu.qml +++ b/tests/auto/accessibility/data/menu.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/pageindicator.qml b/tests/auto/accessibility/data/pageindicator.qml index b42d3f9e..666414e7 100644 --- a/tests/auto/accessibility/data/pageindicator.qml +++ b/tests/auto/accessibility/data/pageindicator.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/popup.qml b/tests/auto/accessibility/data/popup.qml index 70fe2e5f..47e8a04a 100644 --- a/tests/auto/accessibility/data/popup.qml +++ b/tests/auto/accessibility/data/popup.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/progressbar.qml b/tests/auto/accessibility/data/progressbar.qml index 283db003..23cb3731 100644 --- a/tests/auto/accessibility/data/progressbar.qml +++ b/tests/auto/accessibility/data/progressbar.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/radiobutton.qml b/tests/auto/accessibility/data/radiobutton.qml index 1883fff8..e36944cd 100644 --- a/tests/auto/accessibility/data/radiobutton.qml +++ b/tests/auto/accessibility/data/radiobutton.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/rangeslider.qml b/tests/auto/accessibility/data/rangeslider.qml index ce3dc872..ac173034 100644 --- a/tests/auto/accessibility/data/rangeslider.qml +++ b/tests/auto/accessibility/data/rangeslider.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/scrollbar.qml b/tests/auto/accessibility/data/scrollbar.qml index 2e360422..f20bca0a 100644 --- a/tests/auto/accessibility/data/scrollbar.qml +++ b/tests/auto/accessibility/data/scrollbar.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/scrollindicator.qml b/tests/auto/accessibility/data/scrollindicator.qml index e933dece..7d2d5532 100644 --- a/tests/auto/accessibility/data/scrollindicator.qml +++ b/tests/auto/accessibility/data/scrollindicator.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/slider.qml b/tests/auto/accessibility/data/slider.qml index 060bb66c..565d98a9 100644 --- a/tests/auto/accessibility/data/slider.qml +++ b/tests/auto/accessibility/data/slider.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/spinbox.qml b/tests/auto/accessibility/data/spinbox.qml index 9d29bccc..9a0ab5ef 100644 --- a/tests/auto/accessibility/data/spinbox.qml +++ b/tests/auto/accessibility/data/spinbox.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/switch.qml b/tests/auto/accessibility/data/switch.qml index 9913e3f1..17315096 100644 --- a/tests/auto/accessibility/data/switch.qml +++ b/tests/auto/accessibility/data/switch.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/tabbar.qml b/tests/auto/accessibility/data/tabbar.qml index 127c4e81..692e6b2c 100644 --- a/tests/auto/accessibility/data/tabbar.qml +++ b/tests/auto/accessibility/data/tabbar.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/tabbutton.qml b/tests/auto/accessibility/data/tabbutton.qml index cfb04ca2..c5fe646f 100644 --- a/tests/auto/accessibility/data/tabbutton.qml +++ b/tests/auto/accessibility/data/tabbutton.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/textarea.qml b/tests/auto/accessibility/data/textarea.qml index 381c08bd..7c4aa977 100644 --- a/tests/auto/accessibility/data/textarea.qml +++ b/tests/auto/accessibility/data/textarea.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/textfield.qml b/tests/auto/accessibility/data/textfield.qml index 5db46d82..7c7cd009 100644 --- a/tests/auto/accessibility/data/textfield.qml +++ b/tests/auto/accessibility/data/textfield.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/toolbar.qml b/tests/auto/accessibility/data/toolbar.qml index c0503aef..51ba454c 100644 --- a/tests/auto/accessibility/data/toolbar.qml +++ b/tests/auto/accessibility/data/toolbar.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/accessibility/data/toolbutton.qml b/tests/auto/accessibility/data/toolbutton.qml index 63aacddc..ed44c8af 100644 --- a/tests/auto/accessibility/data/toolbutton.qml +++ b/tests/auto/accessibility/data/toolbutton.qml @@ -1,6 +1,6 @@ import QtQuick 2.5 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { visible: true diff --git a/tests/auto/applicationwindow/data/activeFocusControl.qml b/tests/auto/applicationwindow/data/activeFocusControl.qml index b407a91b..8a206aaf 100644 --- a/tests/auto/applicationwindow/data/activeFocusControl.qml +++ b/tests/auto/applicationwindow/data/activeFocusControl.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/applicationwindow/data/activefocusontab.qml b/tests/auto/applicationwindow/data/activefocusontab.qml index 6cbd132f..dc4d2ddb 100644 --- a/tests/auto/applicationwindow/data/activefocusontab.qml +++ b/tests/auto/applicationwindow/data/activefocusontab.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { title: "Test Application Window" diff --git a/tests/auto/applicationwindow/data/attachedProperties.qml b/tests/auto/applicationwindow/data/attachedProperties.qml index 0e518a0b..dd14c30c 100644 --- a/tests/auto/applicationwindow/data/attachedProperties.qml +++ b/tests/auto/applicationwindow/data/attachedProperties.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { property alias childControl: childControl diff --git a/tests/auto/applicationwindow/data/basicapplicationwindow.qml b/tests/auto/applicationwindow/data/basicapplicationwindow.qml index afac65f3..f53035d9 100644 --- a/tests/auto/applicationwindow/data/basicapplicationwindow.qml +++ b/tests/auto/applicationwindow/data/basicapplicationwindow.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { title: "Test Application Window" diff --git a/tests/auto/applicationwindow/data/defaultFocus.qml b/tests/auto/applicationwindow/data/defaultFocus.qml index ed2a9303..9839e15c 100644 --- a/tests/auto/applicationwindow/data/defaultFocus.qml +++ b/tests/auto/applicationwindow/data/defaultFocus.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { visible: true diff --git a/tests/auto/applicationwindow/data/fill.qml b/tests/auto/applicationwindow/data/fill.qml index 02d413b7..ef228e66 100644 --- a/tests/auto/applicationwindow/data/fill.qml +++ b/tests/auto/applicationwindow/data/fill.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml index 629e0cf9..b500c29b 100644 --- a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml +++ b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 200 diff --git a/tests/auto/applicationwindow/data/font.qml b/tests/auto/applicationwindow/data/font.qml index 0bc744b1..d6055de4 100644 --- a/tests/auto/applicationwindow/data/font.qml +++ b/tests/auto/applicationwindow/data/font.qml @@ -39,8 +39,8 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T ApplicationWindow { objectName: "appWin" diff --git a/tests/auto/applicationwindow/data/locale.qml b/tests/auto/applicationwindow/data/locale.qml index d6d46a0d..cb6cb555 100644 --- a/tests/auto/applicationwindow/data/locale.qml +++ b/tests/auto/applicationwindow/data/locale.qml @@ -39,8 +39,8 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T ApplicationWindow { objectName: "appWin" diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp index 02528fdc..b712075f 100644 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp @@ -523,7 +523,7 @@ void tst_applicationwindow::defaultFont() QQmlEngine engine; QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.0; ApplicationWindow { }", QUrl()); + component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl()); QScopedPointer<QQuickApplicationWindow> window; window.reset(static_cast<QQuickApplicationWindow *>(component.create())); diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 91850968..4dabf06f 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -6,6 +6,7 @@ SUBDIRS += \ controls \ drawer \ menu \ + platform \ popup \ pressandhold \ qquickmaterialstyle \ @@ -14,6 +15,7 @@ SUBDIRS += \ qquickstyleselector \ qquickuniversalstyle \ qquickuniversalstyleconf \ + revisions \ sanity \ snippets diff --git a/tests/auto/controls/data/TumblerDatePicker.qml b/tests/auto/controls/data/TumblerDatePicker.qml index 18d7fb97..e5340493 100644 --- a/tests/auto/controls/data/TumblerDatePicker.qml +++ b/tests/auto/controls/data/TumblerDatePicker.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** 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. @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Row { id: datePicker diff --git a/tests/auto/controls/data/TumblerListView.qml b/tests/auto/controls/data/TumblerListView.qml new file mode 100644 index 00000000..cccf8adf --- /dev/null +++ b/tests/auto/controls/data/TumblerListView.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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 + +ListView { + anchors.fill: parent + model: parent.model + delegate: parent.delegate + + snapMode: ListView.SnapToItem + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: height / 2 - (height / parent.visibleItemCount / 2) + preferredHighlightEnd: height / 2 + (height / parent.visibleItemCount / 2) + clip: true +} diff --git a/tests/auto/controls/data/TumblerPathView.qml b/tests/auto/controls/data/TumblerPathView.qml new file mode 100644 index 00000000..e325faf6 --- /dev/null +++ b/tests/auto/controls/data/TumblerPathView.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 + +PathView { + id: pathView + model: parent.model + delegate: parent.delegate + clip: true + pathItemCount: parent.visibleItemCount + 1 + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + dragMargin: width / 2 + + path: Path { + startX: pathView.width / 2 + startY: -pathView.delegateHeight / 2 + PathLine { + x: pathView.width / 2 + y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2 + } + } + + property real delegateHeight: parent.availableHeight / parent.visibleItemCount +} diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index c94653d9..cb12f6f1 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_busyindicator.qml b/tests/auto/controls/data/tst_busyindicator.qml index 142ec70a..c456a2e8 100644 --- a/tests/auto/controls/data/tst_busyindicator.qml +++ b/tests/auto/controls/data/tst_busyindicator.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index f8717a88..cc588016 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -210,8 +210,11 @@ TestCase { control.spy.expectedSequence = repeatSequence mousePress(control) compare(control.pressed, true) - tryCompare(clickSpy, "count", repeatCount) - verify(control.spy.success) + tryVerify(function() { return clickSpy.count >= repeatCount }) + if (clickSpy.count > repeatCount) + warn("Expected auto-repeat count " + repeatCount + " exceeded (" + clickSpy.count + ") - busy CI?") + else + verify(control.spy.success) control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], ["downChanged", { "down": false }], @@ -226,8 +229,11 @@ TestCase { control.spy.expectedSequence = repeatSequence keyPress(Qt.Key_Space) compare(control.pressed, true) - tryCompare(clickSpy, "count", repeatCount) - verify(control.spy.success) + tryVerify(function() { return clickSpy.count >= repeatCount }) + if (clickSpy.count > repeatCount) + warn("Expected auto-repeat count " + repeatCount + " exceeded (" + clickSpy.count + ") - busy CI?") + else + verify(control.spy.success) control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], ["downChanged", { "down": false }], diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml index bb0ffe00..2427999a 100644 --- a/tests/auto/controls/data/tst_buttongroup.qml +++ b/tests/auto/controls/data/tst_buttongroup.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -65,6 +65,11 @@ TestCase { signalName: "buttonsChanged" } + SignalSpy { + id: clickedSpy + signalName: "clicked" + } + function init() { verify(!checkedButtonSpy.target) compare(checkedButtonSpy.count, 0) @@ -217,6 +222,32 @@ TestCase { group.destroy() } + function test_clicked() { + var group = buttonGroup.createObject(testCase) + verify(group) + + clickedSpy.target = group + verify(clickedSpy.valid) + + var button1 = button.createObject(testCase) + var button2 = button.createObject(testCase) + + group.addButton(button1) + group.addButton(button2) + + button1.clicked() + compare(clickedSpy.count, 1) + compare(clickedSpy.signalArguments[0][0], button1) + + button2.clicked() + compare(clickedSpy.count, 2) + compare(clickedSpy.signalArguments[1][0], button2) + + group.destroy() + button1.destroy() + button2.destroy() + } + Component { id: checkBoxes Item { diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml index 7969b589..d1b590e4 100644 --- a/tests/auto/controls/data/tst_checkbox.qml +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_checkdelegate.qml b/tests/auto/controls/data/tst_checkdelegate.qml index a471b1d6..2fa8b4be 100644 --- a/tests/auto/controls/data/tst_checkdelegate.qml +++ b/tests/auto/controls/data/tst_checkdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 29bf62c8..4db8c439 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -41,7 +41,7 @@ import QtQuick 2.2 import QtQuick.Window 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -92,6 +92,7 @@ TestCase { compare(control.count, 0) compare(control.model, undefined) + compare(control.flat, false) compare(control.pressed, false) compare(control.currentIndex, -1) compare(control.highlightedIndex, -1) diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml index 89266d16..fc839493 100644 --- a/tests/auto/controls/data/tst_control.qml +++ b/tests/auto/controls/data/tst_control.qml @@ -40,8 +40,8 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index a2ebf192..e6446d3e 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_dialog.qml b/tests/auto/controls/data/tst_dialog.qml new file mode 100644 index 00000000..44c6e1b8 --- /dev/null +++ b/tests/auto/controls/data/tst_dialog.qml @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** 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.4 +import QtTest 1.0 +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T + +TestCase { + id: testCase + width: 400 + height: 400 + visible: true + when: windowShown + name: "Dialog" + + Component { + id: dialog + Dialog { } + } + + Component { + id: buttonBox + DialogButtonBox { } + } + + Component { + id: headerBox + DialogButtonBox { position: DialogButtonBox.Header } + } + + Component { + id: footerBox + DialogButtonBox { position: DialogButtonBox.Footer } + } + + Component { + id: signalSpy + SignalSpy { } + } + + function test_defaults() { + var control = dialog.createObject(testCase) + verify(control) + verify(!control.header) + verify(!control.footer) + verify(control.buttonBox) + compare(control.standardButtons, 0) + control.destroy() + } + + function test_accept() { + var control = dialog.createObject(testCase) + + control.open() + waitForRendering(control.contentItem) + verify(control.visible) + + var acceptedSpy = signalSpy.createObject(testCase, {target: control, signalName: "accepted"}) + verify(acceptedSpy.valid) + control.accept() + compare(acceptedSpy.count, 1) + + tryCompare(control, "visible", false) + + control.destroy() + } + + function test_reject() { + var control = dialog.createObject(testCase) + + control.open() + waitForRendering(control.contentItem) + verify(control.visible) + + var rejectedSpy = signalSpy.createObject(testCase, {target: control, signalName: "rejected"}) + verify(rejectedSpy.valid) + control.reject() + compare(rejectedSpy.count, 1) + + tryCompare(control, "visible", false) + + control.destroy() + } + + function test_buttonBox_data() { + return [ + { tag: "default header", property: "header", buttonBox: headerBox }, + { tag: "default footer", property: "footer", buttonBox: footerBox }, + { tag: "custom header", property: "header", position: DialogButtonBox.Header }, + { tag: "custom footer", property: "footer", position: DialogButtonBox.Footer } + ] + } + + function test_buttonBox(data) { + var control = dialog.createObject(testCase) + + if (data.buttonBox) + control.buttonBox = data.buttonBox + else + control[data.property] = buttonBox.createObject(testCase, {position: data.position}) + control.standardButtons = Dialog.Ok | Dialog.Cancel + var box = control[data.property] + verify(box) + compare(box.standardButtons, Dialog.Ok | Dialog.Cancel) + + var acceptedSpy = signalSpy.createObject(testCase, {target: control, signalName: "accepted"}) + verify(acceptedSpy.valid) + box.accepted() + compare(acceptedSpy.count, 1) + + var rejectedSpy = signalSpy.createObject(testCase, {target: control, signalName: "rejected"}) + verify(rejectedSpy.valid) + box.rejected() + compare(rejectedSpy.count, 1) + + control.destroy() + } + + function test_standardButtons() { + var control = dialog.createObject(testCase) + + control.standardButtons = Dialog.Ok + + var box = control.footer ? control.footer : control.header + verify(box) + compare(box.count, 1) + var okButton = box.itemAt(0) + verify(okButton) + compare(okButton.text.toUpperCase(), "OK") + + control.standardButtons = Dialog.Cancel + compare(box.count, 1) + var cancelButton = control.footer.itemAt(0) + verify(cancelButton) + compare(cancelButton.text.toUpperCase(), "CANCEL") + + control.standardButtons = Dialog.Ok | Dialog.Cancel + compare(box.count, 2) + if (box.itemAt(0).text.toUpperCase() === "OK") { + okButton = box.itemAt(0) + cancelButton = box.itemAt(1) + } else { + okButton = box.itemAt(1) + cancelButton = box.itemAt(0) + } + verify(okButton) + verify(cancelButton) + compare(okButton.text.toUpperCase(), "OK") + compare(cancelButton.text.toUpperCase(), "CANCEL") + + control.standardButtons = 0 + compare(box.count, 0) + + control.destroy() + } + + function test_warnings() { + var control = dialog.createObject(testCase) + verify(control) + + var testComponent = Qt.createComponent("TestItem.qml") + verify(testComponent) + + control.buttonBox = headerBox + control.header = testComponent.createObject(testCase) + ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: Custom header detected. Cannot assign buttonBox as a header. No standard buttons will appear in the header.") + control.standardButtons = Dialog.Apply + + control.buttonBox = footerBox + control.footer = testComponent.createObject(testCase) + ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: Custom footer detected. Cannot assign buttonBox as a footer. No standard buttons will appear in the footer.") + control.standardButtons = Dialog.Cancel + + control.buttonBox = testComponent + ignoreWarning(Qt.resolvedUrl("tst_dialog.qml") + ":56:9: QML Dialog: buttonBox must be an instance of DialogButtonBox") + control.standardButtons = Dialog.Ok + + control.destroy() + } +} diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml new file mode 100644 index 00000000..8474e89b --- /dev/null +++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import QtQuick.Controls 2.1 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "DialogButtonBox" + + Component { + id: buttonBox + DialogButtonBox { } + } + + Component { + id: button + Button { } + } + + Component { + id: signalSpy + SignalSpy { } + } + + function test_defaults() { + var control = buttonBox.createObject(testCase) + verify(control) + compare(control.count, 0) + verify(control.delegate) + compare(control.standardButtons, 0) + control.destroy() + } + + function test_standardButtons() { + var control = buttonBox.createObject(testCase) + + compare(control.count, 0) + + control.standardButtons = DialogButtonBox.Ok + compare(control.count, 1) + var okButton = control.itemAt(0) + verify(okButton) + compare(okButton.text.toUpperCase(), "OK") + + control.standardButtons = DialogButtonBox.Cancel + compare(control.count, 1) + var cancelButton = control.itemAt(0) + verify(cancelButton) + compare(cancelButton.text.toUpperCase(), "CANCEL") + + control.standardButtons = DialogButtonBox.Ok | DialogButtonBox.Cancel + compare(control.count, 2) + if (control.itemAt(0).text.toUpperCase() === "OK") { + okButton = control.itemAt(0) + cancelButton = control.itemAt(1) + } else { + okButton = control.itemAt(1) + cancelButton = control.itemAt(0) + } + verify(okButton) + verify(cancelButton) + compare(okButton.text.toUpperCase(), "OK") + compare(cancelButton.text.toUpperCase(), "CANCEL") + + control.standardButtons = 0 + compare(control.count, 0) + + control.destroy() + } + + function test_attached() { + var control = buttonBox.createObject(testCase) + + control.standardButtons = DialogButtonBox.Ok + var okButton = control.itemAt(0) + compare(okButton.DialogButtonBox.buttonBox, control) + compare(okButton.DialogButtonBox.buttonRole, DialogButtonBox.AcceptRole) + + var saveButton = button.createObject(control, {text: "Save"}) + compare(saveButton.DialogButtonBox.buttonBox, control) + compare(saveButton.DialogButtonBox.buttonRole, DialogButtonBox.InvalidRole) + saveButton.DialogButtonBox.buttonRole = DialogButtonBox.AcceptRole + compare(saveButton.DialogButtonBox.buttonRole, DialogButtonBox.AcceptRole) + + var closeButton = button.createObject(null, {text: "Save"}) + compare(closeButton.DialogButtonBox.buttonBox, null) + compare(closeButton.DialogButtonBox.buttonRole, DialogButtonBox.InvalidRole) + closeButton.DialogButtonBox.buttonRole = DialogButtonBox.DestructiveRole + compare(closeButton.DialogButtonBox.buttonRole, DialogButtonBox.DestructiveRole) + control.addItem(closeButton) + compare(closeButton.DialogButtonBox.buttonBox, control) + + control.contentModel.clear() + compare(okButton.DialogButtonBox.buttonBox, null) + compare(saveButton.DialogButtonBox.buttonBox, null) + compare(closeButton.DialogButtonBox.buttonBox, null) + + control.destroy() + } + + function test_signals_data() { + return [ + { tag: "Ok", standardButton: DialogButtonBox.Ok, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }, + { tag: "Open", standardButton: DialogButtonBox.Open, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }, + { tag: "Save", standardButton: DialogButtonBox.Save, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }, + { tag: "Cancel", standardButton: DialogButtonBox.Cancel, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" }, + { tag: "Close", standardButton: DialogButtonBox.Close, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" }, + { tag: "Discard", standardButton: DialogButtonBox.Discard, buttonRole: DialogButtonBox.DestructiveRole }, + { tag: "Apply", standardButton: DialogButtonBox.Apply, buttonRole: DialogButtonBox.ApplyRole }, + { tag: "Reset", standardButton: DialogButtonBox.Reset, buttonRole: DialogButtonBox.ResetRole }, + { tag: "RestoreDefaults", standardButton: DialogButtonBox.RestoreDefaults, buttonRole: DialogButtonBox.ResetRole }, + { tag: "Help", standardButton: DialogButtonBox.Help, buttonRole: DialogButtonBox.HelpRole, signalName: "helpRequested" }, + { tag: "SaveAll", standardButton: DialogButtonBox.SaveAll, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }, + { tag: "Yes", standardButton: DialogButtonBox.Yes, buttonRole: DialogButtonBox.YesRole, signalName: "accepted" }, + { tag: "YesToAll", standardButton: DialogButtonBox.YesToAll, buttonRole: DialogButtonBox.YesRole, signalName: "accepted" }, + { tag: "No", standardButton: DialogButtonBox.No, buttonRole: DialogButtonBox.NoRole, signalName: "rejected" }, + { tag: "NoToAll", standardButton: DialogButtonBox.NoToAll, buttonRole: DialogButtonBox.NoRole, signalName: "rejected" }, + { tag: "Abort", standardButton: DialogButtonBox.Abort, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" }, + { tag: "Retry", standardButton: DialogButtonBox.Retry, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }, + { tag: "Ignore", standardButton: DialogButtonBox.Ignore, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" } + ] + } + + function test_signals(data) { + var control = buttonBox.createObject(testCase) + + control.standardButtons = data.standardButton + compare(control.count, 1) + var button = control.itemAt(0) + verify(button) + compare(button.DialogButtonBox.buttonRole, data.buttonRole) + + var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) + verify(clickedSpy.valid) + var roleSpy = signalSpy.createObject(control, {target: control, signalName: data.signalName}) + compare(roleSpy.valid, !!data.signalName) + + button.clicked() + compare(clickedSpy.count, 1) + compare(clickedSpy.signalArguments[0][0], button) + compare(roleSpy.count, !!data.signalName ? 1 : 0) + + control.destroy() + } +} diff --git a/tests/auto/controls/data/tst_drawer.qml b/tests/auto/controls/data/tst_drawer.qml index e08856bd..bfa8dd10 100644 --- a/tests/auto/controls/data/tst_drawer.qml +++ b/tests/auto/controls/data/tst_drawer.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_frame.qml b/tests/auto/controls/data/tst_frame.qml index a96397de..c64b0048 100644 --- a/tests/auto/controls/data/tst_frame.qml +++ b/tests/auto/controls/data/tst_frame.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 0181ea6b..41f1c780 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_itemdelegate.qml b/tests/auto/controls/data/tst_itemdelegate.qml index 37b0db2a..8eafad57 100644 --- a/tests/auto/controls/data/tst_itemdelegate.qml +++ b/tests/auto/controls/data/tst_itemdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml index 6dae0992..b3350cf5 100644 --- a/tests/auto/controls/data/tst_label.qml +++ b/tests/auto/controls/data/tst_label.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_menuitem.qml b/tests/auto/controls/data/tst_menuitem.qml index be0c0652..b5e08866 100644 --- a/tests/auto/controls/data/tst_menuitem.qml +++ b/tests/auto/controls/data/tst_menuitem.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml index bc7afa50..3cd6b7b8 100644 --- a/tests/auto/controls/data/tst_page.qml +++ b/tests/auto/controls/data/tst_page.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml index d1f1223a..a39265c3 100644 --- a/tests/auto/controls/data/tst_pageindicator.qml +++ b/tests/auto/controls/data/tst_pageindicator.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_pane.qml b/tests/auto/controls/data/tst_pane.qml index a0b8a5c8..2f5ddef3 100644 --- a/tests/auto/controls/data/tst_pane.qml +++ b/tests/auto/controls/data/tst_pane.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 72cd6999..759d6988 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -40,13 +40,13 @@ import QtQuick 2.4 import QtTest 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T TestCase { id: testCase - width: 480 - height: 360 + width: 400 + height: 400 visible: true when: windowShown name: "Popup" @@ -443,6 +443,41 @@ TestCase { control.destroy() } + function test_flip_data() { + return [ + {tag: "flip top-bottom", parentX: 0, parentY: 0, popupX: 0, popupY: -50, popupItemX: 0, popupItemY: 50, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "flip bottom-top", parentX: 0, parentY: 300, popupX: 0, popupY: 50, popupItemX: 0, popupItemY: 250, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "flip left-right", parentX: 0, parentY: 0, popupX: -50, popupY: 0, popupItemX: 50, popupItemY: 0, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "flip right-left", parentX: 300, parentY: 0, popupX: 50, popupY: 0, popupItemX: 250, popupItemY: 0, allowVerticalFlip: true, allowHorizontalFlip: true }, + + {tag: "no flip top-bottom", parentX: 0, parentY: 50, popupX: 0, popupY: -50, popupItemX: 0, popupItemY: 0, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "no flip bottom-top", parentX: 0, parentY: 250, popupX: 0, popupY: 50, popupItemX: 0, popupItemY: 300, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "no flip left-right", parentX: 50, parentY: 0, popupX: -50, popupY: 0, popupItemX: 0, popupItemY: 0, allowVerticalFlip: true, allowHorizontalFlip: true }, + {tag: "no flip right-left", parentX: 250, parentY: 0, popupX: 50, popupY: 0, popupItemX: 300, popupItemY: 0, allowVerticalFlip: true, allowHorizontalFlip: true }, + + {tag: "disallow flip top-bottom", parentX: 0, parentY: 0, popupX: 0, popupY: -50, popupItemX: 0, popupItemY: -50, allowVerticalFlip: false, allowHorizontalFlip: false }, + {tag: "disallow flip bottom-top", parentX: 0, parentY: 300, popupX: 0, popupY: 50, popupItemX: 0, popupItemY: 350, allowVerticalFlip: false, allowHorizontalFlip: false }, + {tag: "disallow flip left-right", parentX: 0, parentY: 0, popupX: -50, popupY: 0, popupItemX: -50, popupItemY: 0, allowVerticalFlip: false, allowHorizontalFlip: false }, + {tag: "disallow flip right-left", parentX: 300, parentY: 0, popupX: 50, popupY: 0, popupItemX: 350, popupItemY: 0, allowVerticalFlip: false, allowHorizontalFlip: false } + ] + } + + function test_flip(data) { + var parentItem = rect.createObject(testCase, {color: "red", x: data.parentX, y: data.parentY, width: 100, height: 100}) + verify(parentItem) + + var control = popupControl.createObject(parentItem, {x: data.popupX, y: data.popupY, width: 100, height: 100, allowVerticalFlip: data.allowVerticalFlip, allowHorizontalFlip: data.allowHorizontalFlip}) + verify(control) + + control.open() + verify(control.visible) + + compare(control.contentItem.parent.y, data.popupItemY) + compare(control.contentItem.parent.x, data.popupItemX) + + parentItem.destroy() + } + function test_background() { var control = popupTemplate.createObject(testCase) verify(control) diff --git a/tests/auto/controls/data/tst_progressbar.qml b/tests/auto/controls/data/tst_progressbar.qml index 5603c280..d7280503 100644 --- a/tests/auto/controls/data/tst_progressbar.qml +++ b/tests/auto/controls/data/tst_progressbar.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml index bd3850c8..94e3a2cb 100644 --- a/tests/auto/controls/data/tst_radiobutton.qml +++ b/tests/auto/controls/data/tst_radiobutton.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_radiodelegate.qml b/tests/auto/controls/data/tst_radiodelegate.qml index 1a424a32..66b47b3a 100644 --- a/tests/auto/controls/data/tst_radiodelegate.qml +++ b/tests/auto/controls/data/tst_radiodelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 581a079c..392be018 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -695,4 +695,31 @@ TestCase { control.destroy() } + + function test_hover_data() { + return [ + { tag: "first:true", node: "first", hoverEnabled: true }, + { tag: "first:false", node: "first", hoverEnabled: false }, + { tag: "second:true", node: "second", hoverEnabled: true }, + { tag: "second:false", node: "second", hoverEnabled: false } + ] + } + + function test_hover(data) { + var control = sliderComponent.createObject(testCase, {hoverEnabled: data.hoverEnabled}) + verify(control) + + var node = control[data.node] + compare(control.hovered, false) + compare(node.hovered, false) + + mouseMove(control, node.handle.x + node.handle.width / 2, node.handle.y + node.handle.height / 2) + compare(control.hovered, data.hoverEnabled) + compare(node.hovered, data.hoverEnabled && node.handle.enabled) + + mouseMove(control, node.handle.x - 1, node.handle.y - 1) + compare(node.hovered, false) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 7dc60d97..643dbe33 100644 --- a/tests/auto/controls/data/tst_scrollbar.qml +++ b/tests/auto/controls/data/tst_scrollbar.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -107,6 +107,13 @@ TestCase { compare(vertical.y, 0) verify(vertical.width > 0) compare(vertical.height, container.height) + // vertical scroll bar follows flickable's width + container.width += 10 + compare(vertical.x, container.width - vertical.width) + // ...unless explicitly positioned + vertical.x = 123 + container.width += 10 + compare(vertical.x, 123) var horizontal = scrollBar.createObject() verify(!horizontal.parent) @@ -128,6 +135,13 @@ TestCase { compare(horizontal.y, container.height - horizontal.height) compare(horizontal.width, container.width) verify(horizontal.height > 0) + // horizontal scroll bar follows flickable's height + container.height += 10 + compare(horizontal.y, container.height - horizontal.height) + // ...unless explicitly positioned + horizontal.y = 123 + container.height += 10 + compare(horizontal.y, 123) var velocity = container.maximumFlickVelocity diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index 39b40852..00730bf4 100644 --- a/tests/auto/controls/data/tst_scrollindicator.qml +++ b/tests/auto/controls/data/tst_scrollindicator.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -92,6 +92,13 @@ TestCase { compare(vertical.y, 0) verify(vertical.width > 0) compare(vertical.height, container.height) + // vertical scroll indicator follows flickable's width + container.width += 10 + compare(vertical.x, container.width - vertical.width) + // ...unless explicitly positioned + vertical.x = 123 + container.width += 10 + compare(vertical.x, 123) var horizontal = scrollIndicator.createObject() verify(!horizontal.parent) @@ -113,6 +120,13 @@ TestCase { compare(horizontal.y, container.height - horizontal.height) compare(horizontal.width, container.width) verify(horizontal.height > 0) + // horizontal scroll indicator follows flickable's height + container.height += 10 + compare(horizontal.y, container.height - horizontal.height) + // ...unless explicitly positioned + horizontal.y = 123 + container.height += 10 + compare(horizontal.y, 123) var velocity = container.maximumFlickVelocity diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index bec4d236..f91760e4 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -530,4 +530,24 @@ TestCase { control.destroy() } + + function test_valueAt_data() { + return [ + { tag: "0.0..1.0", from: 0.0, to: 1.0, values: [0.0, 0.2, 0.5, 1.0] }, + { tag: "0..100", from: 0, to: 100, values: [0, 20, 50, 100] }, + { tag: "100..-100", from: 100, to: -100, values: [100, 60, 0, -100] } + ] + } + + function test_valueAt(data) { + var control = slider.createObject(testCase, {from: data.from, to: data.to}) + verify(control) + + compare(control.valueAt(0.0), data.values[0]) + compare(control.valueAt(0.2), data.values[1]) + compare(control.valueAt(0.5), data.values[2]) + compare(control.valueAt(1.0), data.values[3]) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index d8422706..9e836285 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -478,4 +478,33 @@ TestCase { control.destroy() } + + function test_hover_data() { + return [ + { tag: "up:true", button: "up", hoverEnabled: true, value: 50 }, + { tag: "up:false", button: "up", hoverEnabled: false, value: 50 }, + { tag: "up:max", button: "up", hoverEnabled: true, value: 99 }, + { tag: "down:true", button: "down", hoverEnabled: true, value: 50 }, + { tag: "down:false", button: "down", hoverEnabled: false, value: 50 }, + { tag: "down:min", button: "down", hoverEnabled: true, value: 0 } + ] + } + + function test_hover(data) { + var control = spinBox.createObject(testCase, {hoverEnabled: data.hoverEnabled, value: data.value}) + verify(control) + + var button = control[data.button] + compare(control.hovered, false) + compare(button.hovered, false) + + mouseMove(control, button.indicator.x + button.indicator.width / 2, button.indicator.y + button.indicator.height / 2) + compare(control.hovered, data.hoverEnabled) + compare(button.hovered, data.hoverEnabled && button.indicator.enabled) + + mouseMove(control, button.indicator.x - 1, button.indicator.y - 1) + compare(button.hovered, false) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 6d0433d4..2de0fb98 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -59,6 +59,11 @@ TestCase { StackView { } } + Component { + id: signalSpy + SignalSpy { } + } + function test_initialItem() { var control1 = stackView.createObject(testCase) verify(control1) @@ -567,29 +572,60 @@ TestCase { } } - function test_transitions() { + function test_transitions_data() { + return [ + { tag: "undefined", operation: undefined, + pushEnterRuns: [0,1,1,1], pushExitRuns: [0,1,1,1], replaceEnterRuns: [0,0,1,1], replaceExitRuns: [0,0,1,1], popEnterRuns: [0,0,0,1], popExitRuns: [0,0,0,1] }, + { tag: "immediate", operation: StackView.Immediate, + pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] }, + { tag: "push", operation: StackView.PushTransition, + pushEnterRuns: [1,2,3,4], pushExitRuns: [0,1,2,3], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] }, + { tag: "pop", operation: StackView.PopTransition, + pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [1,2,3,4], popExitRuns: [0,1,2,3] }, + { tag: "replace", operation: StackView.ReplaceTransition, + pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [1,2,3,4], replaceExitRuns: [0,1,2,3], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] }, + ] + } + + function test_transitions(data) { var control = transitionView.createObject(testCase) verify(control) - control.push(component) - verify(!control.busy) - compare(control.pushEnterRuns, 0) - compare(control.pushExitRuns, 0) - - control.push(component) + control.push(component, data.operation) tryCompare(control, "busy", false) - compare(control.pushEnterRuns, 1) - compare(control.pushExitRuns, 1) + compare(control.pushEnterRuns, data.pushEnterRuns[0]) + compare(control.pushExitRuns, data.pushExitRuns[0]) + compare(control.replaceEnterRuns, data.replaceEnterRuns[0]) + compare(control.replaceExitRuns, data.replaceExitRuns[0]) + compare(control.popEnterRuns, data.popEnterRuns[0]) + compare(control.popExitRuns, data.popExitRuns[0]) + + control.push(component, data.operation) + tryCompare(control, "busy", false) + compare(control.pushEnterRuns, data.pushEnterRuns[1]) + compare(control.pushExitRuns, data.pushExitRuns[1]) + compare(control.replaceEnterRuns, data.replaceEnterRuns[1]) + compare(control.replaceExitRuns, data.replaceExitRuns[1]) + compare(control.popEnterRuns, data.popEnterRuns[1]) + compare(control.popExitRuns, data.popExitRuns[1]) - control.replace(component) + control.replace(component, data.operation) tryCompare(control, "busy", false) - compare(control.replaceEnterRuns, 1) - compare(control.replaceExitRuns, 1) + compare(control.pushEnterRuns, data.pushEnterRuns[2]) + compare(control.pushExitRuns, data.pushExitRuns[2]) + compare(control.replaceEnterRuns, data.replaceEnterRuns[2]) + compare(control.replaceExitRuns, data.replaceExitRuns[2]) + compare(control.popEnterRuns, data.popEnterRuns[2]) + compare(control.popExitRuns, data.popExitRuns[2]) - control.pop() + control.pop(data.operation) tryCompare(control, "busy", false) - compare(control.popEnterRuns, 1) - compare(control.popExitRuns, 1) + compare(control.pushEnterRuns, data.pushEnterRuns[3]) + compare(control.pushExitRuns, data.pushExitRuns[3]) + compare(control.replaceEnterRuns, data.replaceEnterRuns[3]) + compare(control.replaceExitRuns, data.replaceExitRuns[3]) + compare(control.popEnterRuns, data.popEnterRuns[3]) + compare(control.popExitRuns, data.popExitRuns[3]) control.destroy() } @@ -831,11 +867,11 @@ TestCase { verify(control) ignoreWarning("QQmlComponent: Component is not ready") - ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 File not found") + ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory") control.push(Qt.resolvedUrl("non-existent.qml")) ignoreWarning("QQmlComponent: Component is not ready") - ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 File not found") + ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory") control.replace(Qt.resolvedUrl("non-existent.qml")) control.pop() @@ -861,4 +897,60 @@ TestCase { control.destroy() } + + Component { + id: signalTest + Control { + id: ctrl + property SignalSpy activatedSpy: SignalSpy { target: ctrl.StackView; signalName: "activated" } + property SignalSpy activatingSpy: SignalSpy { target: ctrl.StackView; signalName: "activating" } + property SignalSpy deactivatedSpy: SignalSpy { target: ctrl.StackView; signalName: "deactivated" } + property SignalSpy deactivatingSpy: SignalSpy { target: ctrl.StackView; signalName: "deactivating" } + } + } + + function test_signals() { + var control = stackView.createObject(testCase) + verify(control) + + var item1 = signalTest.createObject(control) + compare(item1.StackView.status, StackView.Inactive) + control.push(item1) + compare(item1.StackView.status, StackView.Active) + compare(item1.activatedSpy.count, 1) + compare(item1.activatingSpy.count, 1) + compare(item1.deactivatedSpy.count, 0) + compare(item1.deactivatingSpy.count, 0) + + var item2 = signalTest.createObject(control) + compare(item2.StackView.status, StackView.Inactive) + control.push(item2) + compare(item2.StackView.status, StackView.Activating) + compare(item2.activatedSpy.count, 0) + compare(item2.activatingSpy.count, 1) + compare(item2.deactivatedSpy.count, 0) + compare(item2.deactivatingSpy.count, 0) + compare(item1.StackView.status, StackView.Deactivating) + compare(item1.activatedSpy.count, 1) + compare(item1.activatingSpy.count, 1) + compare(item1.deactivatedSpy.count, 0) + compare(item1.deactivatingSpy.count, 1) + tryCompare(item2.activatedSpy, "count", 1) + tryCompare(item1.deactivatedSpy, "count", 1) + + control.pop() + compare(item2.StackView.status, StackView.Deactivating) + compare(item2.activatedSpy.count, 1) + compare(item2.activatingSpy.count, 1) + compare(item2.deactivatedSpy.count, 0) + compare(item2.deactivatingSpy.count, 1) + compare(item1.StackView.status, StackView.Activating) + compare(item1.activatedSpy.count, 1) + compare(item1.activatingSpy.count, 2) + compare(item1.deactivatedSpy.count, 1) + compare(item1.deactivatingSpy.count, 1) + tryCompare(item1.activatedSpy, "count", 2) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index a7c084bd..255c1d6d 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -40,7 +40,8 @@ import QtQuick 2.6 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -84,6 +85,12 @@ TestCase { } } + Component { + id: signalSpyComponent + + SignalSpy {} + } + function test_defaults() { var control = swipeDelegateComponent.createObject(testCase); verify(control); @@ -132,7 +139,7 @@ TestCase { verify(control); ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; // Shouldn't be any warnings when unsetting delegates. @@ -141,7 +148,7 @@ TestCase { // right is still set. ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; control.swipe.right = null; @@ -150,11 +157,11 @@ TestCase { control.swipe.behind = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.left = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":79:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.right = itemComponent; control.swipe.behind = null; @@ -169,7 +176,7 @@ TestCase { var oldLeft = control.swipe.left; var oldLeftItem = control.swipe.leftItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.left = null; compare(control.swipe.left, oldLeft); compare(control.swipe.leftItem, oldLeftItem); @@ -180,7 +187,7 @@ TestCase { var oldRight = control.swipe.right; var oldRightItem = control.swipe.rightItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.right = null; compare(control.swipe.right, oldRight); compare(control.swipe.rightItem, oldRightItem); @@ -206,7 +213,7 @@ TestCase { var oldBehind = control.swipe.behind; var oldBehindItem = control.swipe.behindItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":79:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.behind = null; compare(control.swipe.behind, oldBehind); compare(control.swipe.behindItem, oldBehindItem); @@ -216,7 +223,7 @@ TestCase { SignalSequenceSpy { id: mouseSignalSequenceSpy - signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged"] + signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "pressAndHold"] } function test_swipe() { @@ -225,12 +232,17 @@ TestCase { var overDragDistance = dragDistance * 1.1; + var completedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "completed" }); + verify(completedSpy); + verify(completedSpy.valid); + mouseSignalSequenceSpy.target = control; mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); compare(control.swipe.position, 0.0); verify(!control.swipe.complete); + compare(completedSpy.count, 0); verify(mouseSignalSequenceSpy.success); verify(!control.swipe.leftItem); verify(!control.swipe.rightItem); @@ -240,6 +252,7 @@ TestCase { verify(control.pressed); compare(control.swipe.position, overDragDistance / control.width); verify(!control.swipe.complete); + compare(completedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); compare(control.swipe.leftItem.parent, control); @@ -251,6 +264,7 @@ TestCase { verify(control.pressed); compare(control.swipe.position, 0.0); verify(!control.swipe.complete); + compare(completedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); compare(control.swipe.leftItem.parent, control); @@ -263,6 +277,7 @@ TestCase { verify(control.pressed); compare(control.swipe.position, -overDragDistance / control.width); verify(!control.swipe.complete); + compare(completedSpy.count, 0); verify(control.swipe.leftItem); verify(!control.swipe.leftItem.visible); verify(control.swipe.rightItem); @@ -275,6 +290,7 @@ TestCase { verify(control.pressed); compare(control.swipe.position, 0.6); verify(!control.swipe.complete); + compare(completedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); verify(control.swipe.rightItem); @@ -285,6 +301,7 @@ TestCase { verify(!control.pressed); compare(control.swipe.position, 1.0); verify(control.swipe.complete); + compare(completedSpy.count, 1); verify(mouseSignalSequenceSpy.success); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); @@ -300,11 +317,13 @@ TestCase { // complete should still be true, because we haven't moved yet, and hence // haven't started grabbing behind's mouse events. verify(control.swipe.complete); + compare(completedSpy.count, 1); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); verify(control.pressed); verify(!control.swipe.complete); + compare(completedSpy.count, 1); compare(control.swipe.position, 1.0 - overDragDistance / control.width); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; @@ -312,6 +331,7 @@ TestCase { verify(!control.pressed); compare(control.swipe.position, 1.0); verify(control.swipe.complete); + compare(completedSpy.count, 2); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.width + control.leftPadding); @@ -321,11 +341,13 @@ TestCase { verify(control.pressed); compare(control.swipe.position, 1.0); verify(control.swipe.complete); + compare(completedSpy.count, 2); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width * -0.1, control.height / 2); verify(control.pressed); verify(!control.swipe.complete); + compare(completedSpy.count, 2); compare(control.swipe.position, 0.4); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; @@ -333,6 +355,7 @@ TestCase { verify(!control.pressed); compare(control.swipe.position, 0.0); verify(!control.swipe.complete); + compare(completedSpy.count, 2); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.leftPadding); @@ -426,12 +449,6 @@ TestCase { } } - Component { - id: signalSpyComponent - - SignalSpy {} - } - function test_eventsToLeftAndRight() { var control = swipeDelegateWithButtonComponent.createObject(testCase); verify(control); @@ -526,6 +543,26 @@ TestCase { mouseDoubleClickSequence(control, control.width / 2, control.height / 2, Qt.LeftButton); verify(mouseSignalSequenceSpy.success); + // press and hold + var pressAndHoldSpy = signalSpyComponent.createObject(control, { target: control, signalName: "pressAndHold" }); + verify(pressAndHoldSpy); + verify(pressAndHoldSpy.valid); + + mouseSignalSequenceSpy.expectedSequence = [ + ["pressedChanged", { "pressed": true }], + "pressed", + "pressAndHold", + ["pressedChanged", { "pressed": false }], + "released" + ]; + mousePress(control); + compare(control.pressed, true); + tryCompare(pressAndHoldSpy, "count", 1); + + mouseRelease(control); + compare(control.pressed, false); + verify(mouseSignalSequenceSpy.success); + control.destroy(); } @@ -548,8 +585,6 @@ TestCase { text: modelData width: listView.width - onClicked: if (swipe.complete) ListView.view.model.remove(index) - property alias removeAnimation: onRemoveAnimation ListView.onRemove: SequentialAnimation { @@ -574,9 +609,12 @@ TestCase { } swipe.left: Rectangle { - color: rootDelegate.swipe.complete && rootDelegate.pressed ? "#333" : "#444" + objectName: "rectangle" + color: SwipeDelegate.pressed ? "#333" : "#444" anchors.fill: parent + SwipeDelegate.onClicked: listView.model.remove(index) + Label { objectName: "label" text: "Remove" @@ -599,11 +637,14 @@ TestCase { verify(firstItem.pressed); compare(firstItem.swipe.position, 0.0); verify(!firstItem.swipe.complete); + verify(!firstItem.swipe.leftItem); mouseMove(listView, firstItem.width * 1.1, firstItem.height / 2); verify(firstItem.pressed); compare(firstItem.swipe.position, 0.6); verify(!firstItem.swipe.complete); + verify(firstItem.swipe.leftItem); + verify(!firstItem.swipe.leftItem.SwipeDelegate.pressed); mouseRelease(listView, firstItem.width / 2, firstItem.height / 2); verify(!firstItem.pressed); @@ -614,9 +655,23 @@ TestCase { // Wait for it to settle down. tryCompare(firstItem.contentItem, "x", firstItem.leftPadding + firstItem.width); - // Click the button to remove the item. + var leftClickedSpy = signalSpyComponent.createObject(firstItem.swipe.leftItem, + { target: firstItem.swipe.leftItem.SwipeDelegate, signalName: "clicked" }); + verify(leftClickedSpy); + verify(leftClickedSpy.valid); + + // Click the left item to remove the delegate from the list. var contentItemX = firstItem.contentItem.x; - mouseClick(listView, firstItem.width / 2, firstItem.height / 2); + mousePress(listView, firstItem.width / 2, firstItem.height / 2); + verify(firstItem.swipe.leftItem.SwipeDelegate.pressed); + compare(leftClickedSpy.count, 0); + verify(!firstItem.pressed); + + mouseRelease(listView, firstItem.width / 2, firstItem.height / 2); + verify(!firstItem.swipe.leftItem.SwipeDelegate.pressed); + compare(leftClickedSpy.count, 1); + verify(!firstItem.pressed); + leftClickedSpy = null; tryCompare(firstItem.removeAnimation, "running", true); // There was a bug where the resizeContent() would be called because the height // of the control was changing due to the animation. contentItem would then @@ -911,6 +966,160 @@ TestCase { control.destroy(); } + Component { + id: closeSwipeDelegateComponent + + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + + onClicked: close() + + swipe.right: Item { + width: parent.width + height: parent.height + } + } + } + + function test_close() { + var control = swipeDelegateComponent.createObject(testCase); + verify(control); + + swipe(control, 0.0, -1.0); + compare(control.swipe.rightItem.visible, true); + // Should animate, so it shouldn't change right away. + compare(control.swipe.rightItem.x, 0); + tryCompare(control.swipe.rightItem, "x", control.background.x + control.background.width); + + control.destroy(); + } + + Component { + id: multiActionSwipeDelegateComponent + + SwipeDelegate { + text: "SwipeDelegate" + width: 150 + + swipe.right: Item { + objectName: "rightItemRoot" + width: parent.width + height: parent.height + + property alias firstAction: firstAction + property alias secondAction: secondAction + + property int firstClickCount: 0 + property int secondClickCount: 0 + + RowLayout { + anchors.fill: parent + anchors.margins: 5 + + Rectangle { + id: firstAction + Layout.fillWidth: true + Layout.fillHeight: true + color: "tomato" + + SwipeDelegate.onClicked: ++firstClickCount + } + Rectangle { + id: secondAction + Layout.fillWidth: true + Layout.fillHeight: true + color: "navajowhite" + + SwipeDelegate.onClicked: ++secondClickCount + } + } + } + } + } + + // Tests that it's possible to have multiple non-interactive items in one delegate + // (e.g. left/right/behind) that can each receive clicks. + function test_multipleClickableActions() { + var control = multiActionSwipeDelegateComponent.createObject(testCase); + verify(control); + + swipe(control, 0.0, -1.0); + verify(control.swipe.rightItem); + tryCompare(control.swipe, "complete", true); + + var firstClickedSpy = signalSpyComponent.createObject(control, + { target: control.swipe.rightItem.firstAction.SwipeDelegate, signalName: "clicked" }); + verify(firstClickedSpy); + verify(firstClickedSpy.valid); + + // Clicked within rightItem, but not within an item using the attached properties. + mousePress(control, 2, 2); + compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false); + compare(firstClickedSpy.count, 0); + + mouseRelease(control, 2, 2); + compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false); + compare(firstClickedSpy.count, 0); + + // Click within the first item. + mousePress(control.swipe.rightItem.firstAction, 0, 0); + compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, true); + compare(firstClickedSpy.count, 0); + + mouseRelease(control.swipe.rightItem.firstAction, 0, 0); + compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false); + compare(firstClickedSpy.count, 1); + compare(control.swipe.rightItem.firstClickCount, 1); + + var secondClickedSpy = signalSpyComponent.createObject(control, + { target: control.swipe.rightItem.secondAction.SwipeDelegate, signalName: "clicked" }); + verify(secondClickedSpy); + verify(secondClickedSpy.valid); + + // Click within the second item. + mousePress(control.swipe.rightItem.secondAction, 0, 0); + compare(control.swipe.rightItem.secondAction.SwipeDelegate.pressed, true); + compare(secondClickedSpy.count, 0); + + mouseRelease(control.swipe.rightItem.secondAction, 0, 0); + compare(control.swipe.rightItem.secondAction.SwipeDelegate.pressed, false); + compare(secondClickedSpy.count, 1); + compare(control.swipe.rightItem.secondClickCount, 1); + + control.destroy(); + } + + // Pressing on a "side action" and then dragging should eventually + // cause the ListView to grab the mouse and start changing its contentY. + // When this happens, it will grab the mouse and hence we must clear + // that action's pressed state so that it doesn't stay pressed after releasing. + function test_dragSideAction() { + var listView = removableDelegatesComponent.createObject(testCase); + verify(listView); + + var control = listView.itemAt(0, 0); + verify(control); + + // Expose the side action. + swipe(control, 0.0, 1.0); + verify(control.swipe.leftItem); + tryCompare(control.swipe, "complete", true); + + var pressedSpy = signalSpyComponent.createObject(control, + { target: control.swipe.leftItem.SwipeDelegate, signalName: "pressedChanged" }); + verify(pressedSpy); + verify(pressedSpy.valid); + + mouseDrag(listView, 20, 20, 0, listView.height); + compare(pressedSpy.count, 2); + verify(listView.contentY !== 0); + + compare(control.swipe.leftItem.SwipeDelegate.pressed, false); + + listView.destroy(); + } + // When the width of a SwipeDelegate changes (as it does upon portrait => landscape // rotation, for example), the positions of the contentItem and background items // should be updated accordingly. @@ -1011,14 +1220,14 @@ TestCase { function test_horizontalAnchors_data() { return [ - { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":959:25" }, - { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":966:25" }, - { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":973:25" }, - { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":980:25" }, - { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":987:26" }, - { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":994:26" }, - { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":1001:26" }, - { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":1008:26" } + { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":1168:25" }, + { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":1175:25" }, + { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":1182:25" }, + { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":1189:25" }, + { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":1196:26" }, + { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":1203:26" }, + { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":1210:26" }, + { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":1217:26" } ]; } diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index df22bb09..b131236d 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -107,6 +107,16 @@ TestCase { compare(control.currentItem.text, "2") compare(currentItemChangedSpy.count, 3); + control.decrementCurrentIndex() + compare(control.currentIndex, 1) + compare(control.currentItem.text, "1") + compare(currentItemChangedSpy.count, 4); + + control.incrementCurrentIndex() + compare(control.currentIndex, 2) + compare(control.currentItem.text, "2") + compare(currentItemChangedSpy.count, 5); + control.destroy() } @@ -407,6 +417,8 @@ TestCase { property int index: SwipeView.index property SwipeView view: SwipeView.view property bool isCurrentItem: SwipeView.isCurrentItem + property bool isNextItem: SwipeView.isNextItem + property bool isPreviousItem: SwipeView.isPreviousItem } } @@ -427,11 +439,15 @@ TestCase { compare(control.itemAt(i).text, titles[i]) compare(control.itemAt(i).SwipeView.index, i) compare(control.itemAt(i).SwipeView.isCurrentItem, i === 0) + compare(control.itemAt(i).SwipeView.isNextItem, i === 1) + compare(control.itemAt(i).SwipeView.isPreviousItem, false) } control.currentIndex = data.currentBefore for (i = 0; i < control.count; ++i) { compare(control.itemAt(i).SwipeView.isCurrentItem, i === data.currentBefore) + compare(control.itemAt(i).SwipeView.isNextItem, i === data.currentBefore + 1) + compare(control.itemAt(i).SwipeView.isPreviousItem, i === data.currentBefore - 1) } control.moveItem(data.from, data.to) @@ -448,6 +464,8 @@ TestCase { compare(control.itemAt(i).text, titles[i]) compare(control.itemAt(i).SwipeView.index, i); compare(control.itemAt(i).SwipeView.isCurrentItem, i === data.currentAfter) + compare(control.itemAt(i).SwipeView.isNextItem, i === data.currentAfter + 1) + compare(control.itemAt(i).SwipeView.isPreviousItem, i === data.currentAfter - 1) } control.destroy() @@ -492,12 +510,16 @@ TestCase { compare(page.view, null); compare(page.index, -1); compare(page.isCurrentItem, false); + compare(page.isNextItem, false); + compare(page.isPreviousItem, false); page.destroy(); page = pageAttached.createObject(null); compare(page.view, null); compare(page.index, -1); compare(page.isCurrentItem, false); + compare(page.isNextItem, false); + compare(page.isPreviousItem, false); control.insertItem(0, page); compare(control.count, 1); @@ -505,6 +527,8 @@ TestCase { compare(page.view, control); compare(page.index, 0); compare(page.isCurrentItem, true); + compare(page.isNextItem, false); + compare(page.isPreviousItem, false); control.removeItem(0); compare(control.count, 0); @@ -512,6 +536,8 @@ TestCase { compare(page.view, null); compare(page.index, -1); compare(page.isCurrentItem, false); + compare(page.isNextItem, false); + compare(page.isPreviousItem, false); control.destroy(); } diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index f12e7612..b75e2713 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_switchdelegate.qml b/tests/auto/controls/data/tst_switchdelegate.qml index 231736c6..2d5c6089 100644 --- a/tests/auto/controls/data/tst_switchdelegate.qml +++ b/tests/auto/controls/data/tst_switchdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml index b46f7f00..666fc2cb 100644 --- a/tests/auto/controls/data/tst_tabbar.qml +++ b/tests/auto/controls/data/tst_tabbar.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -144,6 +144,16 @@ TestCase { compare(control.currentItem.text, "2") compare(control.currentItem.checked, true) + control.decrementCurrentIndex() + compare(control.currentIndex, 1) + compare(control.currentItem.text, "1") + compare(control.currentItem.checked, true) + + control.incrementCurrentIndex() + compare(control.currentIndex, 2) + compare(control.currentItem.text, "2") + compare(control.currentItem.checked, true) + control.destroy() } diff --git a/tests/auto/controls/data/tst_tabbutton.qml b/tests/auto/controls/data/tst_tabbutton.qml index 4ab9d955..77d22a48 100644 --- a/tests/auto/controls/data/tst_tabbutton.qml +++ b/tests/auto/controls/data/tst_tabbutton.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index bda0b3e3..5d3e8d55 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -199,6 +199,196 @@ TestCase { testCase.TextArea.flickable = null } + function test_hover_data() { + return [ + { tag: "enabled", hoverEnabled: true }, + { tag: "disabled", hoverEnabled: false }, + ] + } + + function test_hover(data) { + var control = textArea.createObject(testCase, {text: "TextArea", hoverEnabled: data.hoverEnabled}) + verify(control) + + compare(control.hovered, false) + + mouseMove(control) + compare(control.hovered, data.hoverEnabled) + + mouseMove(control, -1, -1) + compare(control.hovered, false) + + control.destroy() + } + + function test_pressedReleased_data() { + return [ + { + tag: "pressed outside", x: -1, y: -1, button: Qt.LeftButton, + controlPressEvent: null, + controlReleaseEvent: null, + parentPressEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentReleaseEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + }, + { + tag: "left click", x: 0, y: 0, button: Qt.LeftButton, + controlPressEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + controlReleaseEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentPressEvent: null, + parentReleaseEvent: null, + }, + { + tag: "right click", x: 0, y: 0, button: Qt.RightButton, + controlPressEvent: { + x: 0, y: 0, button: Qt.RightButton, buttons: Qt.RightButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + controlReleaseEvent: { + x: 0, y: 0, button: Qt.RightButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentPressEvent: null, + parentReleaseEvent: null, + }, + ]; + } + + Component { + id: mouseAreaComponent + MouseArea { + anchors.fill: parent + } + } + + function checkMouseEvent(event, expectedEvent) { + compare(event.x, expectedEvent.x) + compare(event.y, expectedEvent.y) + compare(event.button, expectedEvent.button) + compare(event.buttons, expectedEvent.buttons) + } + + function test_pressedReleased(data) { + var mouseArea = mouseAreaComponent.createObject(testCase) + verify(mouseArea) + var control = textArea.createObject(mouseArea, {text: "TextArea"}) + verify(control) + + // Give enough room to check presses outside of the control and on the parent. + control.x = 1; + control.y = 1; + + function checkControlPressEvent(event) { + checkMouseEvent(event, data.controlPressEvent) + } + function checkControlReleaseEvent(event) { + checkMouseEvent(event, data.controlReleaseEvent) + } + function checkParentPressEvent(event) { + checkMouseEvent(event, data.parentPressEvent) + } + function checkParentReleaseEvent(event) { + checkMouseEvent(event, data.parentReleaseEvent) + } + + // Can't use signalArguments, because the event won't live that long. + if (data.controlPressEvent) + control.onPressed.connect(checkControlPressEvent) + if (data.controlReleaseEvent) + control.onReleased.connect(checkControlReleaseEvent) + if (data.parentPressEvent) + control.onPressed.connect(checkParentPressEvent) + if (data.parentReleaseEvent) + control.onReleased.connect(checkParentReleaseEvent) + + var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" }) + verify(controlPressedSpy.valid) + var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" }) + verify(controlReleasedSpy.valid) + var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" }) + verify(parentPressedSpy.valid) + var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" }) + verify(parentReleasedSpy.valid) + + mousePress(control, data.x, data.y, data.button) + compare(controlPressedSpy.count, data.controlPressEvent ? 1 : 0) + compare(parentPressedSpy.count, data.parentPressEvent ? 1 : 0) + mouseRelease(control, data.x, data.y, data.button) + compare(controlReleasedSpy.count, data.controlReleaseEvent ? 1 : 0) + compare(parentReleasedSpy.count, data.parentReleaseEvent ? 1 : 0) + + mouseArea.destroy() + } + + Component { + id: ignoreTextArea + + TextArea { + property bool ignorePress: false + property bool ignoreRelease: false + + onPressed: if (ignorePress) event.accepted = false + onReleased: if (ignoreRelease) event.accepted = false + } + } + + function checkEventAccepted(event) { + compare(event.accepted, true) + } + + function checkEventIgnored(event) { + compare(event.accepted, false) + } + + function test_ignorePressRelease() { + var mouseArea = mouseAreaComponent.createObject(testCase) + verify(mouseArea) + var control = ignoreTextArea.createObject(mouseArea) + verify(control) + + var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" }) + verify(controlPressedSpy.valid) + var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" }) + verify(controlReleasedSpy.valid) + var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" }) + verify(parentPressedSpy.valid) + var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" }) + verify(parentReleasedSpy.valid) + + // Ignore only press events. + control.onPressed.connect(checkEventIgnored) + control.ignorePress = true + mousePress(control, 0, 0, data.button) + // The control will still get the signal, it just won't accept the event. + compare(controlPressedSpy.count, 1) + compare(parentPressedSpy.count, 1) + mouseRelease(control, 0, 0, data.button) + compare(controlReleasedSpy.count, 0) + compare(parentReleasedSpy.count, 1) + control.onPressed.disconnect(checkEventIgnored) + + // Ignore only release events. + control.onPressed.connect(checkEventAccepted) + control.onReleased.connect(checkEventIgnored) + control.ignorePress = false + control.ignoreRelease = true + mousePress(control, 0, 0, data.button) + compare(controlPressedSpy.count, 2) + compare(parentPressedSpy.count, 1) + mouseRelease(control, 0, 0, data.button) + compare(controlReleasedSpy.count, 1) + compare(parentReleasedSpy.count, 1) + control.onPressed.disconnect(checkEventAccepted) + control.onReleased.disconnect(checkEventIgnored) + + mouseArea.destroy() + } + function test_multiClick() { var control = textArea.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) verify(control) diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index f2907b36..1f1de748 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -145,6 +145,196 @@ TestCase { control.destroy() } + function test_hover_data() { + return [ + { tag: "enabled", hoverEnabled: true }, + { tag: "disabled", hoverEnabled: false }, + ] + } + + function test_hover(data) { + var control = textField.createObject(testCase, {hoverEnabled: data.hoverEnabled}) + verify(control) + + compare(control.hovered, false) + + mouseMove(control) + compare(control.hovered, data.hoverEnabled) + + mouseMove(control, -1, -1) + compare(control.hovered, false) + + control.destroy() + } + + function test_pressedReleased_data() { + return [ + { + tag: "pressed outside", x: -1, y: -1, button: Qt.LeftButton, + controlPressEvent: null, + controlReleaseEvent: null, + parentPressEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentReleaseEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + }, + { + tag: "left click", x: 0, y: 0, button: Qt.LeftButton, + controlPressEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + controlReleaseEvent: { + x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentPressEvent: null, + parentReleaseEvent: null, + }, + { + tag: "right click", x: 0, y: 0, button: Qt.RightButton, + controlPressEvent: { + x: 0, y: 0, button: Qt.RightButton, buttons: Qt.RightButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + controlReleaseEvent: { + x: 0, y: 0, button: Qt.RightButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false + }, + parentPressEvent: null, + parentReleaseEvent: null, + }, + ]; + } + + Component { + id: mouseAreaComponent + MouseArea { + anchors.fill: parent + } + } + + function checkMouseEvent(event, expectedEvent) { + compare(event.x, expectedEvent.x) + compare(event.y, expectedEvent.y) + compare(event.button, expectedEvent.button) + compare(event.buttons, expectedEvent.buttons) + } + + function test_pressedReleased(data) { + var mouseArea = mouseAreaComponent.createObject(testCase) + verify(mouseArea) + var control = textField.createObject(mouseArea) + verify(control) + + // Give enough room to check presses outside of the control and on the parent. + control.x = 1; + control.y = 1; + + function checkControlPressEvent(event) { + checkMouseEvent(event, data.controlPressEvent) + } + function checkControlReleaseEvent(event) { + checkMouseEvent(event, data.controlReleaseEvent) + } + function checkParentPressEvent(event) { + checkMouseEvent(event, data.parentPressEvent) + } + function checkParentReleaseEvent(event) { + checkMouseEvent(event, data.parentReleaseEvent) + } + + // Can't use signalArguments, because the event won't live that long. + if (data.controlPressEvent) + control.onPressed.connect(checkControlPressEvent) + if (data.controlReleaseEvent) + control.onReleased.connect(checkControlReleaseEvent) + if (data.parentPressEvent) + control.onPressed.connect(checkParentPressEvent) + if (data.parentReleaseEvent) + control.onReleased.connect(checkParentReleaseEvent) + + var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" }) + verify(controlPressedSpy.valid) + var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" }) + verify(controlReleasedSpy.valid) + var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" }) + verify(parentPressedSpy.valid) + var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" }) + verify(parentReleasedSpy.valid) + + mousePress(control, data.x, data.y, data.button) + compare(controlPressedSpy.count, data.controlPressEvent ? 1 : 0) + compare(parentPressedSpy.count, data.parentPressEvent ? 1 : 0) + mouseRelease(control, data.x, data.y, data.button) + compare(controlReleasedSpy.count, data.controlReleaseEvent ? 1 : 0) + compare(parentReleasedSpy.count, data.parentReleaseEvent ? 1 : 0) + + mouseArea.destroy() + } + + Component { + id: ignoreTextField + + TextField { + property bool ignorePress: false + property bool ignoreRelease: false + + onPressed: if (ignorePress) event.accepted = false + onReleased: if (ignoreRelease) event.accepted = false + } + } + + function checkEventAccepted(event) { + compare(event.accepted, true) + } + + function checkEventIgnored(event) { + compare(event.accepted, false) + } + + function test_ignorePressRelease() { + var mouseArea = mouseAreaComponent.createObject(testCase) + verify(mouseArea) + var control = ignoreTextField.createObject(mouseArea) + verify(control) + + var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" }) + verify(controlPressedSpy.valid) + var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" }) + verify(controlReleasedSpy.valid) + var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" }) + verify(parentPressedSpy.valid) + var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" }) + verify(parentReleasedSpy.valid) + + // Ignore only press events. + control.onPressed.connect(checkEventIgnored) + control.ignorePress = true + mousePress(control, 0, 0, data.button) + // The control will still get the signal, it just won't accept the event. + compare(controlPressedSpy.count, 1) + compare(parentPressedSpy.count, 1) + mouseRelease(control, 0, 0, data.button) + compare(controlReleasedSpy.count, 0) + compare(parentReleasedSpy.count, 1) + control.onPressed.disconnect(checkEventIgnored) + + // Ignore only release events. + control.onPressed.connect(checkEventAccepted) + control.onReleased.connect(checkEventIgnored) + control.ignorePress = false + control.ignoreRelease = true + mousePress(control, 0, 0, data.button) + compare(controlPressedSpy.count, 2) + compare(parentPressedSpy.count, 1) + mouseRelease(control, 0, 0, data.button) + compare(controlReleasedSpy.count, 1) + compare(parentReleasedSpy.count, 1) + control.onPressed.disconnect(checkEventAccepted) + control.onReleased.disconnect(checkEventIgnored) + + mouseArea.destroy() + } + function test_multiClick() { var control = textField.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true}) verify(control) diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml index b68f26e6..cc64383e 100644 --- a/tests/auto/controls/data/tst_toolbar.qml +++ b/tests/auto/controls/data/tst_toolbar.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml index 1417c8e2..cc41d942 100644 --- a/tests/auto/controls/data/tst_toolbutton.qml +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_toolseparator.qml b/tests/auto/controls/data/tst_toolseparator.qml new file mode 100644 index 00000000..47eb933f --- /dev/null +++ b/tests/auto/controls/data/tst_toolseparator.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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.8 +import QtTest 1.0 +import QtQuick.Controls 2.1 + +TestCase { + id: testCase + width: 400 + height: 400 + visible: true + name: "ToolSeparator" + + Component { + id: toolSeparator + ToolSeparator {} + } + + function test_size() { + var control = toolSeparator.createObject(testCase); + verify(control); + verify(control.width > 1); + verify(control.height > 1); + + control.destroy(); + } + + Component { + id: signalSpyComponent + SignalSpy {} + } + + function test_orientation() { + var control = toolSeparator.createObject(testCase); + verify(control); + compare(control.horizontal, false); + compare(control.vertical, true); + + var orientationSpy = signalSpyComponent.createObject(control, { target: control, signalName: "orientationChanged" }); + + var originalWidth = control.width; + var originalHeight = control.height; + control.orientation = Qt.Horizontal; + compare(control.orientation, Qt.Horizontal); + compare(control.width, originalHeight); + compare(control.height, originalWidth); + compare(control.horizontal, true); + compare(control.vertical, false); + compare(orientationSpy.count, 1); + + control.orientation = Qt.Vertical; + compare(control.orientation, Qt.Vertical); + compare(control.width, originalWidth); + compare(control.height, originalHeight); + compare(control.horizontal, false); + compare(control.vertical, true); + compare(orientationSpy.count, 2); + + control.destroy(); + } +} diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index 04064fa1..1e6ecf01 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -40,7 +40,7 @@ import QtQuick 2.4 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index 22cde065..6f1f0200 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TestCase { id: testCase @@ -55,15 +55,34 @@ TestCase { readonly property real implicitTumblerHeight: 200 readonly property real defaultImplicitDelegateHeight: implicitTumblerHeight / 3 readonly property real defaultListViewTumblerOffset: -defaultImplicitDelegateHeight + readonly property real tumblerDelegateHeight: tumbler ? tumbler.availableHeight / tumbler.visibleItemCount : 0 + property Item tumblerView: null + + Component { + id: tumblerComponent + + Tumbler { + visibleItemCount: 3 + } + } function init() { - tumbler = Qt.createQmlObject("import QtQuick.Controls 2.0; Tumbler { }", testCase, ""); - verify(tumbler, "Tumbler: failed to create an instance"); - compare(tumbler.contentItem.parent, tumbler); + createTumbler(); } function cleanup() { tumbler.destroy(); + tumblerView = null; + } + + function createTumbler(args) { + if (args === undefined) + tumbler = tumblerComponent.createObject(testCase); + else + tumbler = tumblerComponent.createObject(testCase, args); + verify(tumbler, "Tumbler: failed to create an instance"); + tumblerView = findView(tumbler); + verify(tumblerView); } function tumblerXCenter() { @@ -76,24 +95,45 @@ TestCase { // visualItemIndex is from 0 to the amount of visible items. function itemCenterPos(visualItemIndex) { - var halfDelegateHeight = tumbler.contentItem.delegateHeight / 2; + var halfDelegateHeight = tumblerDelegateHeight / 2; var yCenter = tumbler.y + tumbler.topPadding + halfDelegateHeight - + (tumbler.contentItem.delegateHeight * visualItemIndex); + + (tumblerDelegateHeight * visualItemIndex); return Qt.point(tumblerXCenter(), yCenter); } function checkItemSizes() { - var contentChildren = tumbler.contentItem.hasOwnProperty("contentItem") - ? tumbler.contentItem.contentItem.children : tumbler.contentItem.children; + var contentChildren = tumbler.wrap ? tumblerView.children : tumblerView.contentItem.children; verify(contentChildren.length >= tumbler.count); for (var i = 0; i < contentChildren.length; ++i) { - compare(contentChildren[i].width, tumbler.width); - compare(contentChildren[i].height, tumbler.contentItem.delegateHeight); + compare(contentChildren[i].width, tumbler.availableWidth); + compare(contentChildren[i].height, tumblerDelegateHeight); } } - function tst_dynamicContentItemChange() { - // test that currentIndex is maintained between contentItem changes... + function findView(parent) { + for (var i = 0; i < parent.children.length; ++i) { + var child = parent.children[i]; + if (child.hasOwnProperty("currentIndex")) { + return child; + } + + return findView(child); + } + + return null; + } + + property Component noAttachedPropertiesDelegate: Text { + text: modelData + } + + function test_wrapWithoutAttachedProperties() { + verify(tumbler.wrap); + + tumbler.delegate = noAttachedPropertiesDelegate; + // Shouldn't assert. + tumbler.wrap = false; + verify(findView(tumbler)); } function test_currentIndex() { @@ -104,69 +144,191 @@ TestCase { // Set it through user interaction. var pos = Qt.point(tumblerXCenter(), tumbler.height / 2); - mouseDrag(tumbler, pos.x, pos.y, 0, -tumbler.contentItem.delegateHeight / 2, Qt.LeftButton, Qt.NoModifier, 200); - compare(tumbler.currentIndex, 1); - compare(tumbler.contentItem.currentIndex, 1); + mouseDrag(tumbler, pos.x, pos.y, 0, tumbler.height / 3, Qt.LeftButton, Qt.NoModifier, 200); + tryCompare(tumblerView, "offset", 1); + compare(tumbler.currentIndex, 4); + compare(tumblerView.currentIndex, 4); // Set it manually. tumbler.currentIndex = 2; tryCompare(tumbler, "currentIndex", 2); - compare(tumbler.contentItem.currentIndex, 2); + compare(tumblerView.currentIndex, 2); - // PathView has 0 as its currentIndex in this case for some reason. tumbler.model = null; - tryCompare(tumbler, "currentIndex", 0); + tryCompare(tumbler, "currentIndex", -1); + // PathView will only use 0 as the currentIndex when there are no items. + compare(tumblerView.currentIndex, 0); tumbler.model = ["A", "B", "C"]; tryCompare(tumbler, "currentIndex", 0); + + // Setting a negative current index should have no effect, because the model isn't empty. + tumbler.currentIndex = -1; + compare(tumbler.currentIndex, 0); + + tumbler.model = 1; + compare(tumbler.currentIndex, 0); + + tumbler.model = 5; + compare(tumbler.count, 5); + tumblerView = findView(tumbler); + tryCompare(tumblerView, "count", 5); + tumbler.currentIndex = 4; + compare(tumbler.currentIndex, 4); + compare(tumblerView.currentIndex, 4); + + --tumbler.model; + compare(tumbler.count, 4); + compare(tumblerView.count, 4); + // Removing an item from an integer-based model will cause views to reset their currentIndex to 0. + compare(tumbler.currentIndex, 0); + compare(tumblerView.currentIndex, 0); + + tumbler.model = 0; + compare(tumbler.currentIndex, -1); + } + + Component { + id: currentIndexTumbler + + Tumbler { + model: 5 + currentIndex: 2 + visibleItemCount: 3 + } + } + + Component { + id: currentIndexTumblerNoWrap + + Tumbler { + model: 5 + currentIndex: 2 + wrap: false + visibleItemCount: 3 + } + } + + Component { + id: currentIndexTumblerNoWrapReversedOrder + + Tumbler { + model: 5 + wrap: false + currentIndex: 2 + visibleItemCount: 3 + } + } + + Component { + id: negativeCurrentIndexTumblerNoWrap + + Tumbler { + model: 5 + wrap: false + currentIndex: -1 + visibleItemCount: 3 + } + } + + Component { + id: currentIndexTooLargeTumbler + + Tumbler { + objectName: "currentIndexTooLargeTumbler" + model: 10 + currentIndex: 10 + } + } + + + function test_currentIndexAtCreation_data() { + return [ + { tag: "wrap: implicit, expected currentIndex: 2", currentIndex: 2, wrap: true, component: currentIndexTumbler }, + { tag: "wrap: false, expected currentIndex: 2", currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrap }, + // Order of property assignments shouldn't matter + { tag: "wrap: false, expected currentIndex: 2, reversed property assignment order", + currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrapReversedOrder }, + { tag: "wrap: false, expected currentIndex: 0", currentIndex: 0, wrap: false, component: negativeCurrentIndexTumblerNoWrap }, + { tag: "wrap: implicit, expected currentIndex: 0", currentIndex: 0, wrap: true, component: currentIndexTooLargeTumbler } + ] + } + + function test_currentIndexAtCreation(data) { + // Test setting currentIndex at creation time + var tumbler = data.component.createObject(testCase); + verify(tumbler); + // A "statically declared" currentIndex will be pending until the count has changed, + // which happens when the model is set, which happens on the TumblerView's next polish. + tryCompare(tumbler, "currentIndex", data.currentIndex); + + tumblerView = findView(tumbler); + // TODO: replace once QTBUG-19708 is fixed. + for (var delay = 1000; delay >= 0; delay -= 50) { + if (tumblerView.currentItem) + break; + wait(50); + } + verify(tumblerView.currentItem); + compare(tumblerView.currentIndex, data.currentIndex); + compare(tumblerView.currentItem.text, data.currentIndex.toString()); + + var fuzz = 1; + if (data.wrap) { + fuzzyCompare(tumblerView.offset, data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0, fuzz); + } else { + fuzzyCompare(tumblerView.contentY, tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin, fuzz); + } + + tumbler.destroy(); } function test_keyboardNavigation() { tumbler.model = 5; tumbler.forceActiveFocus(); - tumbler.contentItem.highlightMoveDuration = 0; + tumblerView.highlightMoveDuration = 0; // Navigate upwards through entire wheel. for (var j = 0; j < tumbler.count - 1; ++j) { keyClick(Qt.Key_Up, Qt.NoModifier); - tryCompare(tumbler.contentItem, "offset", j + 1); + tryCompare(tumblerView, "offset", j + 1); compare(tumbler.currentIndex, tumbler.count - 1 - j); } keyClick(Qt.Key_Up, Qt.NoModifier); - tryCompare(tumbler.contentItem, "offset", 0); + tryCompare(tumblerView, "offset", 0); compare(tumbler.currentIndex, 0); // Navigate downwards through entire wheel. for (j = 0; j < tumbler.count - 1; ++j) { keyClick(Qt.Key_Down, Qt.NoModifier); - tryCompare(tumbler.contentItem, "offset", tumbler.count - 1 - j); + tryCompare(tumblerView, "offset", tumbler.count - 1 - j); compare(tumbler.currentIndex, j + 1); } keyClick(Qt.Key_Down, Qt.NoModifier); - tryCompare(tumbler.contentItem, "offset", 0); + tryCompare(tumblerView, "offset", 0); compare(tumbler.currentIndex, 0); } function test_itemsCorrectlyPositioned() { tumbler.model = 4; tumbler.height = 120; - compare(tumbler.contentItem.delegateHeight, 40); + compare(tumblerDelegateHeight, 40); checkItemSizes(); - wait(tumbler.contentItem.highlightMoveDuration); + wait(tumblerView.highlightMoveDuration); var firstItemCenterPos = itemCenterPos(1); - var firstItem = tumbler.contentItem.itemAt(firstItemCenterPos.x, firstItemCenterPos.y); + var firstItem = tumblerView.itemAt(firstItemCenterPos.x, firstItemCenterPos.y); var actualPos = testCase.mapFromItem(firstItem, 0, 0); compare(actualPos.x, tumbler.leftPadding); compare(actualPos.y, tumbler.topPadding + 40); tumbler.forceActiveFocus(); keyClick(Qt.Key_Down); - tryCompare(tumbler.contentItem, "offset", 3.0); + tryCompare(tumblerView, "offset", 3.0); firstItemCenterPos = itemCenterPos(0); - firstItem = tumbler.contentItem.itemAt(firstItemCenterPos.x, firstItemCenterPos.y); + firstItem = tumblerView.itemAt(firstItemCenterPos.x, firstItemCenterPos.y); verify(firstItem); // Test QTBUG-40298. actualPos = testCase.mapFromItem(firstItem, 0, 0); @@ -174,12 +336,12 @@ TestCase { compare(actualPos.y, tumbler.topPadding); var secondItemCenterPos = itemCenterPos(1); - var secondItem = tumbler.contentItem.itemAt(secondItemCenterPos.x, secondItemCenterPos.y); + var secondItem = tumblerView.itemAt(secondItemCenterPos.x, secondItemCenterPos.y); verify(secondItem); verify(firstItem.y < secondItem.y); var thirdItemCenterPos = itemCenterPos(2); - var thirdItem = tumbler.contentItem.itemAt(thirdItemCenterPos.x, thirdItemCenterPos.y); + var thirdItem = tumblerView.itemAt(thirdItemCenterPos.x, thirdItemCenterPos.y); verify(thirdItem); verify(firstItem.y < thirdItem.y); verify(secondItem.y < thirdItem.y); @@ -207,18 +369,18 @@ TestCase { tumbler = component.createObject(testCase); // Should not be any warnings. - compare(tumbler.dayTumbler.currentIndex, 0); + tryCompare(tumbler.dayTumbler, "currentIndex", 0); compare(tumbler.dayTumbler.count, 31); compare(tumbler.monthTumbler.currentIndex, 0); compare(tumbler.monthTumbler.count, 12); compare(tumbler.yearTumbler.currentIndex, 0); compare(tumbler.yearTumbler.count, 100); - verify(tumbler.dayTumbler.contentItem.children.length >= tumbler.dayTumbler.visibleItemCount); - verify(tumbler.monthTumbler.contentItem.children.length >= tumbler.monthTumbler.visibleItemCount); + verify(findView(tumbler.dayTumbler).children.length >= tumbler.dayTumbler.visibleItemCount); + verify(findView(tumbler.monthTumbler).children.length >= tumbler.monthTumbler.visibleItemCount); // TODO: do this properly somehow wait(100); - verify(tumbler.yearTumbler.contentItem.children.length >= tumbler.yearTumbler.visibleItemCount); + verify(findView(tumbler.yearTumbler).children.length >= tumbler.yearTumbler.visibleItemCount); // March. tumbler.monthTumbler.currentIndex = 2; @@ -291,22 +453,101 @@ TestCase { function test_displacement(data) { // TODO: test setting these in the opposite order (delegate after model // doesn't seem to cause a change in delegates in PathView) + tumbler.wrap = true; tumbler.delegate = displacementDelegate; tumbler.model = data.count; compare(tumbler.count, data.count); - var delegate = findChild(tumbler.contentItem, "delegate" + data.index); + var delegate = findChild(tumblerView, "delegate" + data.index); verify(delegate); - tumbler.contentItem.offset = data.offset; + tumblerView.offset = data.offset; compare(delegate.displacement, data.expectedDisplacement); // test displacement after adding and removing items } + function test_wrap() { + tumbler.model = 5; + compare(tumbler.count, 5); + + tumbler.currentIndex = 2; + compare(tumblerView.currentIndex, 2); + + tumbler.wrap = false; + tumblerView = findView(tumbler); + compare(tumbler.count, 5); + compare(tumbler.currentIndex, 2); + // Tumbler's count hasn't changed (the model hasn't changed), + // but the new view needs time to instantiate its items. + tryCompare(tumblerView, "count", 5); + compare(tumblerView.currentIndex, 2); + } + Component { - id: listViewTumblerComponent - //! [contentItem] + id: twoItemTumbler + + Tumbler { + model: 2 + } + } + + Component { + id: tenItemTumbler + + Tumbler { + model: 10 + } + } + + function test_countWrap() { + // Check that a count that is less than visibleItemCount results in wrap being set to false. + verify(2 < tumbler.visibleItemCount); + tumbler.model = 2; + compare(tumbler.count, 2); + compare(tumbler.wrap, false); + } + + function test_explicitlyNonwrapping() { + // Check that explicitly setting wrap to false works even when it was implicitly false. + var explicitlyNonWrapping = twoItemTumbler.createObject(testCase); + verify(explicitlyNonWrapping); + tryCompare(explicitlyNonWrapping, "wrap", false); + + explicitlyNonWrapping.wrap = false; + // wrap shouldn't be set to true now that there are more items than there are visible ones. + verify(10 > explicitlyNonWrapping.visibleItemCount); + explicitlyNonWrapping.model = 10; + compare(explicitlyNonWrapping.wrap, false); + + // Test resetting wrap back to the default behavior. + explicitlyNonWrapping.wrap = undefined; + compare(explicitlyNonWrapping.wrap, true); + + explicitlyNonWrapping.destroy(); + } + + function test_explicitlyWrapping() { + // Check that explicitly setting wrap to true works even when it was implicitly true. + var explicitlyWrapping = tenItemTumbler.createObject(testCase); + verify(explicitlyWrapping); + compare(explicitlyWrapping.wrap, true); + + explicitlyWrapping.wrap = true; + // wrap shouldn't be set to false now that there are more items than there are visible ones. + explicitlyWrapping.model = 2; + compare(explicitlyWrapping.wrap, true); + + // Test resetting wrap back to the default behavior. + explicitlyWrapping.wrap = undefined; + compare(explicitlyWrapping.wrap, false); + + explicitlyWrapping.destroy(); + } + + Component { + id: customListViewTumblerComponent + Tumbler { id: listViewTumbler @@ -322,7 +563,95 @@ TestCase { clip: true } } - //! [contentItem] + } + + Component { + id: customPathViewTumblerComponent + + Tumbler { + id: pathViewTumbler + + contentItem: PathView { + id: pathView + model: pathViewTumbler.model + delegate: pathViewTumbler.delegate + clip: true + pathItemCount: pathViewTumbler.visibleItemCount + 1 + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + dragMargin: width / 2 + + path: Path { + startX: pathView.width / 2 + startY: -pathView.delegateHeight / 2 + PathLine { + x: pathView.width / 2 + y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2 + } + } + + property real delegateHeight: pathViewTumbler.availableHeight / pathViewTumbler.visibleItemCount + } + } + } + + function test_customContentItemAtConstruction_data() { + return [ + { tag: "ListView", component: customListViewTumblerComponent }, + { tag: "PathView", component: customPathViewTumblerComponent } + ]; + } + + function test_customContentItemAtConstruction(data) { + var tumbler = data.component.createObject(testCase); + // Shouldn't assert. + + tumbler.model = 5; + compare(tumbler.count, 5); + + tumbler.currentIndex = 2; + var tumblerView = findView(tumbler); + compare(tumblerView.currentIndex, 2); + + tumblerView.incrementCurrentIndex(); + compare(tumblerView.currentIndex, 3); + compare(tumbler.currentIndex, 3); + + // Shouldn't have any affect. + tumbler.wrap = false; + compare(tumbler.count, 5); + compare(tumblerView.currentIndex, 3); + compare(tumbler.currentIndex, 3); + + tumbler.destroy(); + } + + function test_customContentItemAfterConstruction_data() { + return [ + { tag: "ListView", componentPath: "TumblerListView.qml" }, + { tag: "PathView", componentPath: "TumblerPathView.qml" } + ]; + } + + function test_customContentItemAfterConstruction(data) { + tumbler.model = 5; + compare(tumbler.count, 5); + + tumbler.currentIndex = 2; + compare(tumblerView.currentIndex, 2); + + var contentItemComponent = Qt.createComponent(data.componentPath); + compare(contentItemComponent.status, Component.Ready); + + var customContentItem = contentItemComponent.createObject(tumbler); + tumbler.contentItem = customContentItem; + compare(tumbler.count, 5); + tumblerView = findView(tumbler); + compare(tumblerView.currentIndex, 2); + + tumblerView.incrementCurrentIndex(); + compare(tumblerView.currentIndex, 3); + compare(tumbler.currentIndex, 3); } function test_displacementListView_data() { @@ -363,21 +692,16 @@ TestCase { } function test_displacementListView(data) { - tumbler.destroy(); - // Sanity check that they're aren't any children at this stage. - tryCompare(testCase.children, "length", 0); - - tumbler = listViewTumblerComponent.createObject(testCase); - verify(tumbler); - + tumbler.wrap = false; tumbler.delegate = displacementDelegate; tumbler.model = 5; compare(tumbler.count, 5); // Ensure assumptions about the tumbler used in our data() function are correct. - compare(tumbler.contentItem.contentY, -defaultImplicitDelegateHeight); + tumblerView = findView(tumbler); + compare(tumblerView.contentY, -defaultImplicitDelegateHeight); var delegateCount = 0; - var listView = tumbler.contentItem; - var listViewContentItem = tumbler.contentItem.contentItem; + var listView = tumblerView; + var listViewContentItem = tumblerView.contentItem; // We use the mouse instead of setting contentY directly, otherwise the // items snap back into place. This doesn't seem to be an issue for @@ -437,18 +761,15 @@ TestCase { } function test_listViewFlickAboveBounds(data) { - tumbler.destroy(); - - tumbler = listViewTumblerComponent.createObject(testCase); - verify(tumbler); - + tumbler.wrap = false; tumbler.delegate = displacementDelegate; tumbler.model = data.model; + tumblerView = findView(tumbler); mousePress(tumbler, tumblerXCenter(), tumblerYCenter()); // Ensure it's stationary. - var listView = tumbler.contentItem; + var listView = tumblerView; compare(listView.contentY, defaultListViewTumblerOffset); // We could just move up until the contentY changed, but this is safer. @@ -513,9 +834,9 @@ TestCase { for (var delegateIndex = 0; delegateIndex < data.visibleItemCount; ++delegateIndex) { if (data.expectedYPositions.hasOwnProperty(delegateIndex)) { - var delegate = findChild(tumbler.contentItem, "delegate" + delegateIndex); + var delegate = findChild(tumblerView, "delegate" + delegateIndex); verify(delegate, "Delegate found at index " + delegateIndex); - var expectedYPos = data.expectedYPositions[delegateIndex] * tumbler.contentItem.delegateHeight; + var expectedYPos = data.expectedYPositions[delegateIndex] * tumblerDelegateHeight; compare(delegate.mapToItem(tumbler.contentItem, 0, 0).y, expectedYPos); } } @@ -529,12 +850,6 @@ TestCase { property real displacement: Tumbler.displacement } - property Component gridViewComponent: GridView {} - property Component simpleDisplacementDelegate: Text { - property real displacement: Tumbler.displacement - property int index: -1 - } - function test_attachedProperties() { // TODO: crashes somewhere in QML's guts // tumbler.model = 5; @@ -543,18 +858,12 @@ TestCase { // // Cause displacement to be changed. The warning isn't triggered if we don't do this. // tumbler.contentItem.offset += 1; - ignoreWarning("Tumbler: attached properties must be accessed from within a delegate item that has a parent"); + ignoreWarning("Tumbler: attached properties must be accessed through a delegate item that has a parent"); noParentDelegateComponent.createObject(null); ignoreWarning("Tumbler: attempting to access attached property on item without an \"index\" property"); var object = noParentDelegateComponent.createObject(testCase); object.destroy(); - - // Should not be any warnings from this, as ListView, for example, doesn't produce warnings for the same code. - var gridView = gridViewComponent.createObject(testCase); - object = simpleDisplacementDelegate.createObject(gridView); - object.destroy(); - gridView.destroy(); } property Component paddingDelegate: Text { @@ -651,8 +960,8 @@ TestCase { } // Force new items to be created, as there was a bug where the path was correct until this happened. - compare(tumbler.contentItem.offset, 0); + compare(tumblerView.offset, 0); ++tumbler.currentIndex; - tryCompare(tumbler.contentItem, "offset", 4, tumbler.contentItem.highlightMoveDuration * 2); + tryCompare(tumblerView, "offset", 4, tumblerView.highlightMoveDuration * 2); } } diff --git a/tests/auto/controls/default/dependencies.qml b/tests/auto/controls/default/dependencies.qml new file mode 100644 index 00000000..091ab39f --- /dev/null +++ b/tests/auto/controls/default/dependencies.qml @@ -0,0 +1,5 @@ +import QtTest 1.0 +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +TestCase { } diff --git a/tests/auto/controls/material/dependencies.qml b/tests/auto/controls/material/dependencies.qml new file mode 100644 index 00000000..fe0de037 --- /dev/null +++ b/tests/auto/controls/material/dependencies.qml @@ -0,0 +1,6 @@ +import QtTest 1.0 +import QtQuick 2.6 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 + +TestCase { } diff --git a/tests/auto/controls/universal/dependencies.qml b/tests/auto/controls/universal/dependencies.qml new file mode 100644 index 00000000..97da9810 --- /dev/null +++ b/tests/auto/controls/universal/dependencies.qml @@ -0,0 +1,6 @@ +import QtTest 1.0 +import QtQuick 2.6 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Universal 2.1 + +TestCase { } diff --git a/tests/auto/drawer/data/applicationwindow.qml b/tests/auto/drawer/data/applicationwindow.qml index a8ae69ed..a826efab 100644 --- a/tests/auto/drawer/data/applicationwindow.qml +++ b/tests/auto/drawer/data/applicationwindow.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/focus/data/activeFocusOnTab.qml b/tests/auto/focus/data/activeFocusOnTab.qml index 249cdba9..08cf6e3e 100644 --- a/tests/auto/focus/data/activeFocusOnTab.qml +++ b/tests/auto/focus/data/activeFocusOnTab.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Item { id: main diff --git a/tests/auto/focus/data/keyNavigation.qml b/tests/auto/focus/data/keyNavigation.qml index 3be791b5..d17d79f3 100644 --- a/tests/auto/focus/data/keyNavigation.qml +++ b/tests/auto/focus/data/keyNavigation.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Item { id: main diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp index 2c9573c6..cab2625a 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -124,7 +124,7 @@ void tst_focus::policy() { QQmlEngine engine; QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.0; ApplicationWindow { width: 100; height: 100; Control { anchors.fill: parent } }", QUrl()); + component.setData("import QtQuick.Controls 2.1; ApplicationWindow { width: 100; height: 100; Control { anchors.fill: parent } }", QUrl()); QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create())); QVERIFY(window); @@ -207,7 +207,7 @@ void tst_focus::reason() QQmlEngine engine; QQmlComponent component(&engine); - component.setData(QString("import QtQuick.Controls 2.0; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl()); + component.setData(QString("import QtQuick.Controls 2.1; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl()); QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create())); QVERIFY(window.data()); diff --git a/tests/auto/menu/data/addItem.qml b/tests/auto/menu/data/addItem.qml index 7bf07ecb..81814f06 100644 --- a/tests/auto/menu/data/addItem.qml +++ b/tests/auto/menu/data/addItem.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 200 diff --git a/tests/auto/menu/data/applicationwindow.qml b/tests/auto/menu/data/applicationwindow.qml index 03bbe67b..6ac2e88e 100644 --- a/tests/auto/menu/data/applicationwindow.qml +++ b/tests/auto/menu/data/applicationwindow.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { title: "Test Application Window" diff --git a/tests/auto/menu/data/menuSeparator.qml b/tests/auto/menu/data/menuSeparator.qml new file mode 100644 index 00000000..913e8e98 --- /dev/null +++ b/tests/auto/menu/data/menuSeparator.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.1 + +ApplicationWindow { + width: 200 + height: 200 + + property alias menu: menu + + MenuItem { + id: newMenuItem + text: qsTr("New") + } + + MenuSeparator { + id: menuSeparator + } + + MenuItem { + id: saveMenuItem + text: qsTr("Save") + } + + Menu { + id: menu + + Component.onCompleted: { + addItem(newMenuItem) + addItem(menuSeparator) + addItem(saveMenuItem) + } + } +} diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index dc9c296a..28882f04 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -50,6 +50,7 @@ #include <QtQuickTemplates2/private/qquickbutton_p.h> #include <QtQuickTemplates2/private/qquickmenu_p.h> #include <QtQuickTemplates2/private/qquickmenuitem_p.h> +#include <QtQuickTemplates2/private/qquickmenuseparator_p.h> using namespace QQuickVisualTestUtil; @@ -65,6 +66,7 @@ private slots: void contextMenuKeyboard(); void menuButton(); void addItem(); + void menuSeparator(); }; void tst_menu::defaults() @@ -272,6 +274,49 @@ void tst_menu::addItem() QTRY_VERIFY(!menu->isVisible()); } +void tst_menu::menuSeparator() +{ + QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml")); + QQuickApplicationWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value<QQuickMenu*>(); + QVERIFY(menu); + menu->open(); + QVERIFY(menu->isVisible()); + + QQuickMenuItem *newMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(0)); + QVERIFY(newMenuItem); + QCOMPARE(newMenuItem->text(), QStringLiteral("New")); + + QQuickMenuSeparator *menuSeparator = qobject_cast<QQuickMenuSeparator*>(menu->itemAt(1)); + QVERIFY(menuSeparator); + + QQuickMenuItem *saveMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(2)); + QVERIFY(saveMenuItem); + QCOMPARE(saveMenuItem->text(), QStringLiteral("Save")); + QTRY_VERIFY(!QQuickItemPrivate::get(saveMenuItem)->culled); // QTBUG-53262 + + // Clicking on items should still close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + newMenuItem->mapToScene(QPointF(newMenuItem->width() / 2, newMenuItem->height() / 2)).toPoint()); + QTRY_VERIFY(!menu->isVisible()); + + menu->open(); + QVERIFY(menu->isVisible()); + + // Clicking on a separator shouldn't close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + menuSeparator->mapToScene(QPointF(menuSeparator->width() / 2, menuSeparator->height() / 2)).toPoint()); + QVERIFY(menu->isVisible()); + + // Clicking on items should still close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint()); + QTRY_VERIFY(!menu->isVisible()); +} + QTEST_MAIN(tst_menu) #include "tst_menu.moc" diff --git a/tests/auto/platform/data/tst_colordialog.qml b/tests/auto/platform/data/tst_colordialog.qml new file mode 100644 index 00000000..1e9bbccf --- /dev/null +++ b/tests/auto/platform/data/tst_colordialog.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "ColorDialog" + + Component { + id: colorDialog + ColorDialog { } + } + + function test_instance() { + var dialog = colorDialog.createObject(testCase) + verify(dialog) + dialog.destroy() + } +} diff --git a/tests/auto/platform/data/tst_filedialog.qml b/tests/auto/platform/data/tst_filedialog.qml new file mode 100644 index 00000000..1f34c5a7 --- /dev/null +++ b/tests/auto/platform/data/tst_filedialog.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "FileDialog" + + Component { + id: fileDialog + FileDialog { } + } + + function test_instance() { + var dialog = fileDialog.createObject(testCase) + verify(dialog) + dialog.destroy() + } +} diff --git a/tests/auto/platform/data/tst_folderdialog.qml b/tests/auto/platform/data/tst_folderdialog.qml new file mode 100644 index 00000000..9061d825 --- /dev/null +++ b/tests/auto/platform/data/tst_folderdialog.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "FolderDialog" + + Component { + id: folderDialog + FolderDialog { } + } + + function test_instance() { + var dialog = folderDialog.createObject(testCase) + verify(dialog) + dialog.destroy() + } +} diff --git a/tests/auto/platform/data/tst_fontdialog.qml b/tests/auto/platform/data/tst_fontdialog.qml new file mode 100644 index 00000000..b05737aa --- /dev/null +++ b/tests/auto/platform/data/tst_fontdialog.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "FontDialog" + + Component { + id: fontDialog + FontDialog { } + } + + function test_instance() { + var dialog = fontDialog.createObject(testCase) + verify(dialog) + dialog.destroy() + } +} diff --git a/tests/auto/platform/data/tst_menu.qml b/tests/auto/platform/data/tst_menu.qml new file mode 100644 index 00000000..cc846d99 --- /dev/null +++ b/tests/auto/platform/data/tst_menu.qml @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "Menu" + + Component { + id: item + MenuItem { } + } + + Component { + id: menu + Menu { } + } + + SignalSpy { + id: itemsSpy + signalName: "itemsChanged" + } + + function init() { + verify(!itemsSpy.target) + compare(itemsSpy.count, 0) + } + + function cleanup() { + itemsSpy.target = null + itemsSpy.clear() + } + + function test_addRemove() { + var control = menu.createObject(testCase) + + itemsSpy.target = control + verify(itemsSpy.valid) + + control.addItem(item.createObject(control, {text: "1"})) + compare(control.items.length, 1) + compare(control.items[0].text, "1") + compare(itemsSpy.count, 1) + + control.addItem(item.createObject(control, {text: "2"})) + compare(control.items.length, 2) + compare(control.items[0].text, "1") + compare(control.items[1].text, "2") + compare(itemsSpy.count, 2) + + control.insertItem(1, item.createObject(control, {text: "3"})) + compare(control.items.length, 3) + compare(control.items[0].text, "1") + compare(control.items[1].text, "3") + compare(control.items[2].text, "2") + compare(itemsSpy.count, 3) + + control.insertItem(0, item.createObject(control, {text: "4"})) + compare(control.items.length, 4) + compare(control.items[0].text, "4") + compare(control.items[1].text, "1") + compare(control.items[2].text, "3") + compare(control.items[3].text, "2") + compare(itemsSpy.count, 4) + + control.insertItem(control.items.length, item.createObject(control, {text: "5"})) + compare(control.items.length, 5) + compare(control.items[0].text, "4") + compare(control.items[1].text, "1") + compare(control.items[2].text, "3") + compare(control.items[3].text, "2") + compare(control.items[4].text, "5") + compare(itemsSpy.count, 5) + + control.removeItem(control.items[4]) + compare(control.items.length, 4) + compare(control.items[0].text, "4") + compare(control.items[1].text, "1") + compare(control.items[2].text, "3") + compare(control.items[3].text, "2") + compare(itemsSpy.count, 6) + + control.removeItem(control.items[0]) + compare(control.items.length, 3) + compare(control.items[0].text, "1") + compare(control.items[1].text, "3") + compare(control.items[2].text, "2") + compare(itemsSpy.count, 7) + + control.removeItem(control.items[1]) + compare(control.items.length, 2) + compare(control.items[0].text, "1") + compare(control.items[1].text, "2") + compare(itemsSpy.count, 8) + + control.removeItem(control.items[1]) + compare(control.items.length, 1) + compare(control.items[0].text, "1") + compare(itemsSpy.count, 9) + + control.removeItem(control.items[0]) + compare(control.items.length, 0) + compare(itemsSpy.count, 10) + + control.destroy() + } + + Component { + id: contentMenu + Menu { + QtObject { objectName: "object" } + MenuItem { objectName: "item1" } + Timer { objectName: "timer" } + MenuItem { objectName: "item2" } + Component { MenuItem { } } + } + } + + function test_content() { + var control = contentMenu.createObject(testCase) + + function compareObjectNames(content, names) { + if (content.length !== names.length) + return false + for (var i = 0; i < names.length; ++i) { + if (content[i].objectName !== names[i]) + return false + } + return true + } + + itemsSpy.target = control + verify(itemsSpy.valid) + + verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", ""])) + verify(compareObjectNames(control.items, ["item1", "item2"])) + + control.addItem(item.createObject(control, {objectName: "item3"})) + verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", "", "item3"])) + verify(compareObjectNames(control.items, ["item1", "item2", "item3"])) + compare(itemsSpy.count, 1) + + control.insertItem(0, item.createObject(control, {objectName: "item4"})) + verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", "", "item3", "item4"])) + verify(compareObjectNames(control.items, ["item4", "item1", "item2", "item3"])) + compare(itemsSpy.count, 2) + + control.removeItem(control.items[1]) + verify(compareObjectNames(control.data, ["object", "timer", "item2", "", "item3", "item4"])) + verify(compareObjectNames(control.items, ["item4", "item2", "item3"])) + compare(itemsSpy.count, 3) + + control.destroy() + } + + Component { + id: dynamicMenu + Menu { + id: dmenu + MenuItem { text: "static" } + Component.onCompleted: { + addItem(item.createObject(dmenu, {text: "added"})) + insertItem(0, item.createObject(dmenu, {text: "inserted"})) + } + } + } + + function test_dynamic() { + var control = dynamicMenu.createObject(testCase) + + // insertItem(), addItem(), and static MenuItem {} + compare(control.items.length, 3) + compare(control.items[0].text, "inserted") + + var dying = item.createObject(control, {text: "dying"}) + control.addItem(dying) + compare(control.items.length, 4) + compare(control.items[3].text, "dying") + dying.destroy() + wait(0) + compare(control.items.length, 3) + + control.destroy() + } + + function test_type() { + // Q_ENUMS(QPlatformMenu::MenuType) + compare(Menu.DefaultMenu, 0) + compare(Menu.EditMenu, 1) + } +} diff --git a/tests/auto/platform/data/tst_menubar.qml b/tests/auto/platform/data/tst_menubar.qml new file mode 100644 index 00000000..6c29f164 --- /dev/null +++ b/tests/auto/platform/data/tst_menubar.qml @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "MenuBar" + + Component { + id: menu + Menu { } + } + + Component { + id: menuBar + MenuBar { } + } + + SignalSpy { + id: menusSpy + signalName: "menusChanged" + } + + function init() { + verify(!menusSpy.target) + compare(menusSpy.count, 0) + } + + function cleanup() { + menusSpy.target = null + menusSpy.clear() + } + + function test_addRemove() { + var control = menuBar.createObject(testCase) + + menusSpy.target = control + verify(menusSpy.valid) + + control.addMenu(menu.createObject(control, {title: "1"})) + compare(control.menus.length, 1) + compare(control.menus[0].title, "1") + compare(menusSpy.count, 1) + + control.addMenu(menu.createObject(control, {title: "2"})) + compare(control.menus.length, 2) + compare(control.menus[0].title, "1") + compare(control.menus[1].title, "2") + compare(menusSpy.count, 2) + + control.insertMenu(1, menu.createObject(control, {title: "3"})) + compare(control.menus.length, 3) + compare(control.menus[0].title, "1") + compare(control.menus[1].title, "3") + compare(control.menus[2].title, "2") + compare(menusSpy.count, 3) + + control.insertMenu(0, menu.createObject(control, {title: "4"})) + compare(control.menus.length, 4) + compare(control.menus[0].title, "4") + compare(control.menus[1].title, "1") + compare(control.menus[2].title, "3") + compare(control.menus[3].title, "2") + compare(menusSpy.count, 4) + + control.insertMenu(control.menus.length, menu.createObject(control, {title: "5"})) + compare(control.menus.length, 5) + compare(control.menus[0].title, "4") + compare(control.menus[1].title, "1") + compare(control.menus[2].title, "3") + compare(control.menus[3].title, "2") + compare(control.menus[4].title, "5") + compare(menusSpy.count, 5) + + control.removeMenu(control.menus[4]) + compare(control.menus.length, 4) + compare(control.menus[0].title, "4") + compare(control.menus[1].title, "1") + compare(control.menus[2].title, "3") + compare(control.menus[3].title, "2") + compare(menusSpy.count, 6) + + control.removeMenu(control.menus[0]) + compare(control.menus.length, 3) + compare(control.menus[0].title, "1") + compare(control.menus[1].title, "3") + compare(control.menus[2].title, "2") + compare(menusSpy.count, 7) + + control.removeMenu(control.menus[1]) + compare(control.menus.length, 2) + compare(control.menus[0].title, "1") + compare(control.menus[1].title, "2") + compare(menusSpy.count, 8) + + control.removeMenu(control.menus[1]) + compare(control.menus.length, 1) + compare(control.menus[0].title, "1") + compare(menusSpy.count, 9) + + control.removeMenu(control.menus[0]) + compare(control.menus.length, 0) + compare(menusSpy.count, 10) + + control.destroy() + } + + Component { + id: contentBar + MenuBar { + QtObject { objectName: "object" } + Menu { objectName: "menu1" } + Timer { objectName: "timer" } + Menu { objectName: "menu2" } + Component { Menu { } } + } + } + + function test_content() { + var control = contentBar.createObject(testCase) + + function compareObjectNames(content, names) { + if (content.length !== names.length) + return false + for (var i = 0; i < names.length; ++i) { + if (content[i].objectName !== names[i]) + return false + } + return true + } + + menusSpy.target = control + verify(menusSpy.valid) + + verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", ""])) + verify(compareObjectNames(control.menus, ["menu1", "menu2"])) + + control.addMenu(menu.createObject(control, {objectName: "menu3"})) + verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", "", "menu3"])) + verify(compareObjectNames(control.menus, ["menu1", "menu2", "menu3"])) + compare(menusSpy.count, 1) + + control.insertMenu(0, menu.createObject(control, {objectName: "menu4"})) + verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", "", "menu3", "menu4"])) + verify(compareObjectNames(control.menus, ["menu4", "menu1", "menu2", "menu3"])) + compare(menusSpy.count, 2) + + control.removeMenu(control.menus[1]) + verify(compareObjectNames(control.data, ["object", "timer", "menu2", "", "menu3", "menu4"])) + verify(compareObjectNames(control.menus, ["menu4", "menu2", "menu3"])) + compare(menusSpy.count, 3) + + control.destroy() + } + + Component { + id: dynamicBar + MenuBar { + id: dbar + Menu { title: "static" } + Component.onCompleted: { + addMenu(menu.createObject(dbar, {title: "added"})) + insertMenu(0, menu.createObject(dbar, {title: "inserted"})) + } + } + } + + function test_dynamic() { + var control = dynamicBar.createObject(testCase) + + // insertMenu(), addMenu(), and static Menu {} + compare(control.menus.length, 3) + compare(control.menus[0].title, "inserted") + + var dying = menu.createObject(control, {title: "dying"}) + control.addMenu(dying) + compare(control.menus.length, 4) + compare(control.menus[3].title, "dying") + dying.destroy() + wait(0) + compare(control.menus.length, 3) + + control.destroy() + } +} diff --git a/tests/auto/platform/data/tst_menuitem.qml b/tests/auto/platform/data/tst_menuitem.qml new file mode 100644 index 00000000..7c2dd8f5 --- /dev/null +++ b/tests/auto/platform/data/tst_menuitem.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "MenuItem" + + Component { + id: menuItem + MenuItem { } + } + + SignalSpy { + id: spy + } + + function test_properties_data() { + return [ + {tag: "enabled", signal: "enabledChanged", init: true, value: false}, + {tag: "visible", signal: "visibleChanged", init: true, value: false}, + {tag: "separator", signal: "separatorChanged", init: false, value: true}, + {tag: "checkable", signal: "checkableChanged", init: false, value: true}, + {tag: "checked", signal: "checkedChanged", init: false, value: true}, + {tag: "role", signal: "roleChanged", init: MenuItem.TextHeuristicRole, value: MenuItem.AboutRole}, + {tag: "text", signal: "textChanged", init: "", value: "text"}, + {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/undo.png"}, + {tag: "iconName", signal: "iconNameChanged", init: "", value: "edit-undo"}, + {tag: "shortcut", signal: "shortcutChanged", init: undefined, value: StandardKey.Undo} + ] + } + + function test_properties(data) { + var item = menuItem.createObject(testCase) + verify(item) + + spy.target = item + spy.signalName = data.signal + verify(spy.valid) + + compare(item[data.tag], data.init) + item[data.tag] = data.value + compare(spy.count, 1) + compare(item[data.tag], data.value) + + item[data.tag] = data.value + compare(spy.count, 1) + + spy.clear() + item.destroy() + } + + function test_role() { + // Q_ENUMS(QPlatformMenuItem::MenuRole) + compare(MenuItem.NoRole, 0) + compare(MenuItem.TextHeuristicRole, 1) + compare(MenuItem.ApplicationSpecificRole, 2) + compare(MenuItem.AboutQtRole, 3) + compare(MenuItem.AboutRole, 4) + compare(MenuItem.PreferencesRole, 5) + compare(MenuItem.QuitRole, 6) + } +} diff --git a/tests/auto/platform/data/tst_menuitemgroup.qml b/tests/auto/platform/data/tst_menuitemgroup.qml new file mode 100644 index 00000000..31fc18b1 --- /dev/null +++ b/tests/auto/platform/data/tst_menuitemgroup.qml @@ -0,0 +1,380 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "MenuItemGroup" + + Component { + id: menuItemGroup + MenuItemGroup { } + } + + SignalSpy { + id: checkedItemSpy + signalName: "checkedItemChanged" + } + + SignalSpy { + id: itemsSpy + signalName: "itemsChanged" + } + + function init() { + verify(!checkedItemSpy.target) + compare(checkedItemSpy.count, 0) + + verify(!itemsSpy.target) + compare(itemsSpy.count, 0) + } + + function cleanup() { + checkedItemSpy.target = null + checkedItemSpy.clear() + + itemsSpy.target = null + itemsSpy.clear() + } + + function test_null() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + group.addItem(null) + group.removeItem(null) + + group.destroy() + } + + Component { + id: item + MenuItem { } + } + + function test_exclusive() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + compare(group.exclusive, true) + + checkedItemSpy.target = group + verify(checkedItemSpy.valid) + verify(!group.checkedItem) + + var item1 = item.createObject(testCase, {checked: true}) + var item2 = item.createObject(testCase, {checked: false}) + var item3 = item.createObject(testCase, {checked: true}) + + // add checked + group.addItem(item1) + compare(group.checkedItem, item1) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 1) + + // add non-checked + group.addItem(item2) + compare(group.checkedItem, item1) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 1) + + // add checked + group.addItem(item3) + compare(group.checkedItem, item3) + compare(item1.checked, false) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 2) + + // change checked + group.checkedItem = item2 + compare(group.checkedItem, item2) + compare(item1.checked, false) + compare(item2.checked, true) + compare(item3.checked, false) + compare(checkedItemSpy.count, 3) + + // check + item1.checked = true + compare(group.checkedItem, item1) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, false) + compare(checkedItemSpy.count, 4) + + // remove non-checked + group.removeItem(item2) + compare(group.checkedItem, item1) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, false) + compare(checkedItemSpy.count, 4) + + // remove checked + group.removeItem(item1) + compare(group.checkedItem, null) + compare(item1.checked, false) + compare(item2.checked, false) + compare(item3.checked, false) + compare(checkedItemSpy.count, 5) + + group.destroy() + } + + function test_nonExclusive() { + var group = menuItemGroup.createObject(testCase, {exclusive: false}) + verify(group) + + compare(group.exclusive, false) + + checkedItemSpy.target = group + verify(checkedItemSpy.valid) + verify(!group.checkedItem) + + var item1 = item.createObject(testCase, {checked: true}) + var item2 = item.createObject(testCase, {checked: false}) + var item3 = item.createObject(testCase, {checked: true}) + + // add checked + group.addItem(item1) + compare(group.checkedItem, null) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 0) + + // add non-checked + group.addItem(item2) + compare(group.checkedItem, null) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 0) + + // add checked + group.addItem(item3) + compare(group.checkedItem, null) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 0) + + // change checked + group.checkedItem = item2 + compare(group.checkedItem, item2) + compare(item1.checked, true) + compare(item2.checked, true) + compare(item3.checked, true) + compare(checkedItemSpy.count, 1) + + // check + item1.checked = false + item1.checked = true + compare(group.checkedItem, item2) + compare(item1.checked, true) + compare(item2.checked, true) + compare(item3.checked, true) + compare(checkedItemSpy.count, 1) + + // remove checked + group.removeItem(item2) + compare(group.checkedItem, null) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 2) + + // remove non-checked + group.removeItem(item1) + compare(group.checkedItem, null) + compare(item1.checked, true) + compare(item2.checked, false) + compare(item3.checked, true) + compare(checkedItemSpy.count, 2) + + group.destroy() + } + + function test_items() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + itemsSpy.target = group + verify(itemsSpy.valid) + + compare(group.items.length, 0) + compare(group.checkedItem, null) + + var item1 = item.createObject(testCase, {checked: true}) + var item2 = item.createObject(testCase, {checked: false}) + + group.items = [item1, item2] + compare(group.items.length, 2) + compare(group.items[0], item1) + compare(group.items[1], item2) + compare(group.checkedItem, item1) + compare(itemsSpy.count, 2) + + var item3 = item.createObject(testCase, {checked: true}) + + group.addItem(item3) + compare(group.items.length, 3) + compare(group.items[0], item1) + compare(group.items[1], item2) + compare(group.items[2], item3) + compare(group.checkedItem, item3) + compare(itemsSpy.count, 3) + + group.removeItem(item1) + compare(group.items.length, 2) + compare(group.items[0], item2) + compare(group.items[1], item3) + compare(group.checkedItem, item3) + compare(itemsSpy.count, 4) + + group.items = [] + compare(group.items.length, 0) + compare(group.checkedItem, null) + compare(itemsSpy.count, 5) + + group.destroy() + } + + function test_itemDestroyed() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + itemsSpy.target = group + verify(itemsSpy.valid) + + var item1 = item.createObject(testCase, {checked: true}) + + group.addItem(item1) + compare(group.items.length, 1) + compare(group.items[0], item1) + compare(group.checkedItem, item1) + compare(itemsSpy.count, 1) + + item1.destroy() + wait(0) + compare(group.items.length, 0) + compare(group.checkedItem, null) + compare(itemsSpy.count, 2) + + group.destroy() + } + + function test_visible() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + compare(group.visible, true) + + for (var i = 0; i < 3; ++i) { + group.addItem(item.createObject(testCase)) + compare(group.items[i].visible, true) + } + + group.visible = false + compare(group.visible, false) + + for (i = 0; i < 3; ++i) + compare(group.items[i].visible, false) + + group.items[1].visible = true + compare(group.items[1].visible, false) + + group.items[1].visible = false + compare(group.items[1].visible, false) + + group.visible = true + compare(group.visible, true) + + compare(group.items[0].visible, true) + compare(group.items[1].visible, false) + compare(group.items[2].visible, true) + + group.destroy() + } + + function test_enabled() { + var group = menuItemGroup.createObject(testCase) + verify(group) + + compare(group.enabled, true) + + for (var i = 0; i < 3; ++i) { + group.addItem(item.createObject(testCase)) + compare(group.items[i].enabled, true) + } + + group.enabled = false + compare(group.enabled, false) + + for (i = 0; i < 3; ++i) + compare(group.items[i].enabled, false) + + group.items[1].enabled = true + compare(group.items[1].enabled, false) + + group.items[1].enabled = false + compare(group.items[1].enabled, false) + + group.enabled = true + compare(group.enabled, true) + + compare(group.items[0].enabled, true) + compare(group.items[1].enabled, false) + compare(group.items[2].enabled, true) + + group.destroy() + } +} diff --git a/tests/auto/platform/data/tst_menuseparator.qml b/tests/auto/platform/data/tst_menuseparator.qml new file mode 100644 index 00000000..b04a8f31 --- /dev/null +++ b/tests/auto/platform/data/tst_menuseparator.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "MenuSeparator" + + Component { + id: menuSeparator + MenuSeparator { } + } + + function test_separator() { + var separator = menuSeparator.createObject(testCase) + verify(separator) + + compare(separator.separator, true) + + separator.destroy() + } +} diff --git a/tests/auto/platform/data/tst_messagedialog.qml b/tests/auto/platform/data/tst_messagedialog.qml new file mode 100644 index 00000000..ceb6a872 --- /dev/null +++ b/tests/auto/platform/data/tst_messagedialog.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + name: "MessageDialog" + + Component { + id: messageDialog + MessageDialog { } + } + + function test_instance() { + var dialog = messageDialog.createObject(testCase) + verify(dialog) + dialog.destroy() + } +} diff --git a/tests/auto/platform/data/tst_systemtrayicon.qml b/tests/auto/platform/data/tst_systemtrayicon.qml new file mode 100644 index 00000000..58f6401f --- /dev/null +++ b/tests/auto/platform/data/tst_systemtrayicon.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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.2 +import QtTest 1.0 +import Qt.labs.platform 1.0 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "SystemTrayIcon" + + Component { + id: systemTrayIcon + SystemTrayIcon { } + } + + SignalSpy { + id: spy + } + + function test_properties_data() { + return [ + {tag: "visible", signal: "visibleChanged", init: false, value: true}, + {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/tray.png"}, + {tag: "iconName", signal: "iconNameChanged", init: "", value: "icon-name"}, + {tag: "tooltip", signal: "tooltipChanged", init: "", value: "tooltip"}, + ] + } + + function test_properties(data) { + var icon = systemTrayIcon.createObject(testCase) + verify(icon) + + spy.target = icon + spy.signalName = data.signal + verify(spy.valid) + + compare(icon[data.tag], data.init) + icon[data.tag] = data.value + compare(spy.count, 1) + compare(icon[data.tag], data.value) + + icon[data.tag] = data.value + compare(spy.count, 1) + + spy.clear() + icon.destroy() + } +} diff --git a/tests/auto/platform/platform.pro b/tests/auto/platform/platform.pro new file mode 100644 index 00000000..e8f66d13 --- /dev/null +++ b/tests/auto/platform/platform.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = tst_platform +CONFIG += qmltestcase + +SOURCES += \ + $$PWD/tst_platform.cpp + +OTHER_FILES += \ + $$PWD/data/* + +TESTDATA += \ + $$PWD/data/tst_* diff --git a/tests/auto/platform/tst_platform.cpp b/tests/auto/platform/tst_platform.cpp new file mode 100644 index 00000000..3866f7c2 --- /dev/null +++ b/tests/auto/platform/tst_platform.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** 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:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(tst_platform) diff --git a/tests/auto/popup/data/activeFocusOnClose1.qml b/tests/auto/popup/data/activeFocusOnClose1.qml index e1a4cec2..d6b00110 100644 --- a/tests/auto/popup/data/activeFocusOnClose1.qml +++ b/tests/auto/popup/data/activeFocusOnClose1.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/popup/data/activeFocusOnClose2.qml b/tests/auto/popup/data/activeFocusOnClose2.qml index 9418d521..ef5ccfc6 100644 --- a/tests/auto/popup/data/activeFocusOnClose2.qml +++ b/tests/auto/popup/data/activeFocusOnClose2.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/popup/data/applicationwindow.qml b/tests/auto/popup/data/applicationwindow.qml index 2e868192..9b85eb85 100644 --- a/tests/auto/popup/data/applicationwindow.qml +++ b/tests/auto/popup/data/applicationwindow.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { width: 400 diff --git a/tests/auto/pressandhold/data/dependencies.qml b/tests/auto/pressandhold/data/dependencies.qml index caf89569..cd3e88ba 100644 --- a/tests/auto/pressandhold/data/dependencies.qml +++ b/tests/auto/pressandhold/data/dependencies.qml @@ -1,4 +1,4 @@ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Control { } diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp index 713cc60c..2d209788 100644 --- a/tests/auto/pressandhold/tst_pressandhold.cpp +++ b/tests/auto/pressandhold/tst_pressandhold.cpp @@ -67,10 +67,10 @@ void tst_PressAndHold::pressAndHold_data() QTest::addColumn<QByteArray>("data"); QTest::addColumn<QByteArray>("signal"); - QTest::newRow("Button") << QByteArray("import QtQuick.Controls 2.0; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold())); - QTest::newRow("SwipeDelegate") << QByteArray("import QtQuick.Controls 2.0; SwipeDelegate { text: 'SwipeDelegate' }") << QByteArray(SIGNAL(pressAndHold())); - QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.0; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); - QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.0; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); + QTest::newRow("Button") << QByteArray("import QtQuick.Controls 2.1; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold())); + QTest::newRow("SwipeDelegate") << QByteArray("import QtQuick.Controls 2.1; SwipeDelegate { text: 'SwipeDelegate' }") << QByteArray(SIGNAL(pressAndHold())); + QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.1; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); + QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.1; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*))); } void tst_PressAndHold::pressAndHold() @@ -144,8 +144,8 @@ void tst_PressAndHold::keepSelection_data() { QTest::addColumn<QByteArray>("data"); - QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.0; TextField { text: 'TextField' }"); - QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.0; TextArea { text: 'TextArea' }"); + QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.1; TextField { text: 'TextField' }"); + QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.1; TextArea { text: 'TextArea' }"); } void tst_PressAndHold::keepSelection() diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml index 7305b732..8eb6933c 100644 --- a/tests/auto/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml @@ -41,8 +41,8 @@ import QtQuick 2.2 import QtQuick.Window 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 TestCase { id: testCase @@ -578,7 +578,7 @@ TestCase { verify(window) verify(window.pane) - var control = Qt.createQmlObject("import QtQuick.Controls 2.0; " + data.type + " { }", window.pane) + var control = Qt.createQmlObject("import QtQuick.Controls 2.1; " + data.type + " { }", window.pane) verify(control) compare(control.font[data.attribute], data.value) diff --git a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro index eac9bdc4..e4e95ae3 100644 --- a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro +++ b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro @@ -6,7 +6,7 @@ SOURCES += \ $$PWD/tst_qquickmaterialstyle.cpp RESOURCES += \ - $$PWD/qquickmaterialstyle.qrc + $$PWD/qtquickcontrols2.conf OTHER_FILES += \ $$PWD/data/* diff --git a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc deleted file mode 100644 index 53ba6450..00000000 --- a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>qtquickcontrols2.conf</file> -</qresource> -</RCC> diff --git a/tests/auto/qquickstyle/data/dependencies.qml b/tests/auto/qquickstyle/data/dependencies.qml new file mode 100644 index 00000000..cd3e88ba --- /dev/null +++ b/tests/auto/qquickstyle/data/dependencies.qml @@ -0,0 +1,4 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +Control { } diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index b4da3045..11ff58e7 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -58,7 +58,7 @@ void tst_QQuickStyle::lookup() QQmlEngine engine; QQmlComponent component(&engine); - component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Control { }", QUrl()); + component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Control { }", QUrl()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); diff --git a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml b/tests/auto/qquickstyleselector/ResourceStyle/Button.qml index 5b08222c..ee17c230 100644 --- a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml +++ b/tests/auto/qquickstyleselector/ResourceStyle/Button.qml @@ -1,2 +1,2 @@ -import QtQuick.Templates 2.0 as T +import QtQuick.Templates 2.1 as T T.Button { } diff --git a/tests/auto/qquickstyleselector/data/Button.qml b/tests/auto/qquickstyleselector/data/Button.qml index 5b08222c..ee17c230 100644 --- a/tests/auto/qquickstyleselector/data/Button.qml +++ b/tests/auto/qquickstyleselector/data/Button.qml @@ -1,2 +1,2 @@ -import QtQuick.Templates 2.0 as T +import QtQuick.Templates 2.1 as T T.Button { } diff --git a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml b/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml index 5b08222c..ee17c230 100644 --- a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml +++ b/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml @@ -1,2 +1,2 @@ -import QtQuick.Templates 2.0 as T +import QtQuick.Templates 2.1 as T T.Button { } diff --git a/tests/auto/qquickuniversalstyle/data/tst_universal.qml b/tests/auto/qquickuniversalstyle/data/tst_universal.qml index 7ee14da8..2934b444 100644 --- a/tests/auto/qquickuniversalstyle/data/tst_universal.qml +++ b/tests/auto/qquickuniversalstyle/data/tst_universal.qml @@ -41,8 +41,8 @@ import QtQuick 2.2 import QtQuick.Window 2.2 import QtTest 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Universal 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Universal 2.1 TestCase { id: testCase @@ -406,7 +406,7 @@ TestCase { verify(window) verify(window.pane) - var control = Qt.createQmlObject("import QtQuick.Controls 2.0; " + data.type + " { }", window.pane) + var control = Qt.createQmlObject("import QtQuick.Controls 2.1; " + data.type + " { }", window.pane) verify(control) compare(control.font[data.attribute], data.value) diff --git a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro index 83bd19a5..dc81eb9d 100644 --- a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro +++ b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro @@ -6,7 +6,7 @@ SOURCES += \ $$PWD/tst_qquickuniversalstyle.cpp RESOURCES += \ - $$PWD/qquickuniversalstyle.qrc + $$PWD/qtquickcontrols2.conf OTHER_FILES += \ $$PWD/data/* diff --git a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc deleted file mode 100644 index 53ba6450..00000000 --- a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>qtquickcontrols2.conf</file> -</qresource> -</RCC> diff --git a/tests/auto/revisions/data/dependencies.qml b/tests/auto/revisions/data/dependencies.qml new file mode 100644 index 00000000..6f21af18 --- /dev/null +++ b/tests/auto/revisions/data/dependencies.qml @@ -0,0 +1,6 @@ +import QtQuick 2.8 +import QtQuick.Controls 2.0 +import QtQuick.Controls.Material 2.0 +import QtQuick.Controls.Universal 2.0 + +Control { } diff --git a/tests/auto/revisions/revisions.pro b/tests/auto/revisions/revisions.pro new file mode 100644 index 00000000..b3c448da --- /dev/null +++ b/tests/auto/revisions/revisions.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_revisions +SOURCES += tst_revisions.cpp + +macos:CONFIG -= app_bundle + +QT += qml testlib diff --git a/tests/auto/revisions/tst_revisions.cpp b/tests/auto/revisions/tst_revisions.cpp new file mode 100644 index 00000000..33649d62 --- /dev/null +++ b/tests/auto/revisions/tst_revisions.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/qtest.h> +#include <QtTest/qsignalspy.h> +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcomponent.h> + +class tst_revisions : public QObject +{ + Q_OBJECT + +private slots: + void revisions_data(); + void revisions(); +}; + +void tst_revisions::revisions_data() +{ + QTest::addColumn<int>("revision"); + + // In theory, this could be done in a loop from 5.7 to QT_VERSION, but + // the test would immediately fail when the Qt version was bumped up. + // Therefore it is better to just add these lines by hand when adding + // new revisions. + QTest::newRow("2.0") << 0; // Qt 5.7 + QTest::newRow("2.1") << 1; // Qt 5.8 +} + +void tst_revisions::revisions() +{ + QFETCH(int, revision); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QString("import QtQuick 2.0; \ + import QtQuick.Controls 2.%1; \ + import QtQuick.Controls.impl 2.%1; \ + import QtQuick.Controls.Material 2.%1; \ + import QtQuick.Controls.Material.impl 2.%1; \ + import QtQuick.Controls.Universal 2.%1; \ + import QtQuick.Controls.Universal.impl 2.%1; \ + Control { }").arg(revision).toUtf8(), QUrl()); + + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); +} + +QTEST_MAIN(tst_revisions) + +#include "tst_revisions.moc" diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 09cc7f3d..768f3985 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -14,3 +14,7 @@ * [attachedObjects:universal/ComboBox.qml] * +[functions:material/RectangularGlow.qml] +* +[anchors:material/RectangularGlow.qml] +* diff --git a/tests/auto/sanity/data/dependencies.qml b/tests/auto/sanity/data/dependencies.qml index caf89569..cd3e88ba 100644 --- a/tests/auto/sanity/data/dependencies.qml +++ b/tests/auto/sanity/data/dependencies.qml @@ -1,4 +1,4 @@ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Control { } diff --git a/tests/auto/snippets/data/dependencies.qml b/tests/auto/snippets/data/dependencies.qml index aed6ce87..ca36a407 100644 --- a/tests/auto/snippets/data/dependencies.qml +++ b/tests/auto/snippets/data/dependencies.qml @@ -1,6 +1,6 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 import Qt.labs.calendar 1.0 Control { } diff --git a/tests/benchmarks/creationtime/data/dependencies.qml b/tests/benchmarks/creationtime/data/dependencies.qml index 4c1702cc..6b6d951b 100644 --- a/tests/benchmarks/creationtime/data/dependencies.qml +++ b/tests/benchmarks/creationtime/data/dependencies.qml @@ -1,7 +1,7 @@ import QtQuick 2.6 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 -import QtQuick.Controls.Universal 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 +import QtQuick.Controls.Universal 2.1 import Qt.labs.calendar 1.0 Control { } diff --git a/tests/benchmarks/objectcount/data/dependencies.qml b/tests/benchmarks/objectcount/data/dependencies.qml index 4c1702cc..6b6d951b 100644 --- a/tests/benchmarks/objectcount/data/dependencies.qml +++ b/tests/benchmarks/objectcount/data/dependencies.qml @@ -1,7 +1,7 @@ import QtQuick 2.6 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 -import QtQuick.Controls.Universal 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 +import QtQuick.Controls.Universal 2.1 import Qt.labs.calendar 1.0 Control { } diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index 554b8af1..91c17fcc 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -84,7 +84,7 @@ void tst_ObjectCount::init() // warmup QQmlComponent component(&engine); - component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Item { Button {} }", QUrl()); + component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Item { Button {} }", QUrl()); delete component.create(); } diff --git a/tests/manual/buttons/buttons.cpp b/tests/manual/buttons/buttons.cpp new file mode 100644 index 00000000..2f73e3d2 --- /dev/null +++ b/tests/manual/buttons/buttons.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/buttons.qml")); + + return app.exec(); +} diff --git a/tests/manual/buttons/buttons.pro b/tests/manual/buttons/buttons.pro new file mode 100644 index 00000000..d0a6eb28 --- /dev/null +++ b/tests/manual/buttons/buttons.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = buttons +QT += qml quickcontrols2 + +SOURCES += buttons.cpp +RESOURCES += buttons.qml diff --git a/tests/manual/buttons/buttons.qml b/tests/manual/buttons/buttons.qml new file mode 100644 index 00000000..e1a393fd --- /dev/null +++ b/tests/manual/buttons/buttons.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** 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.1 +import QtQuick.Controls.Material 2.1 +import QtQuick.Controls.Universal 2.1 + +ApplicationWindow { + id: window + visible: true + title: "Buttons" + + Component.onCompleted: { + var pane = repeater.itemAt(0) + width = pane.implicitWidth * 2 + flickable.leftMargin + flickable.rightMargin + flow.spacing + height = header.height + pane.implicitHeight * 2 + flickable.topMargin + flickable.bottomMargin + flow.spacing + } + + header: ToolBar { + Row { + spacing: 20 + anchors.right: parent.right + CheckBox { + id: hoverBox + text: "Hover" + checked: true + } + } + } + + Flickable { + id: flickable + anchors.fill: parent + + topMargin: 40 + leftMargin: 40 + rightMargin: 40 + bottomMargin: 40 + + contentHeight: flow.implicitHeight + + Flow { + id: flow + spacing: 40 + width: flickable.width - flickable.leftMargin - flickable.rightMargin + + Repeater { + id: repeater + + model: [ + { title: "Normal", theme: Material.Light, flat: false }, + { title: "Flat", theme: Material.Light, flat: true }, + { title: "Normal", theme: Material.Dark, flat: false }, + { title: "Flat", theme: Material.Dark, flat: true } + ] + + Pane { + Material.elevation: 8 + Material.theme: modelData.theme + Universal.theme: modelData.theme + + GroupBox { + title: modelData.title + background.visible: false + + Grid { + columns: 4 + spacing: 20 + padding: 20 + + Button { text: "Normal"; flat: modelData.flat; hoverEnabled: hoverBox.checked } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; enabled: false } + Button { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; down: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; down: true; enabled: false } + + Button { text: "Checked"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; enabled: false } + Button { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; down: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; down: true; enabled: false } + + Button { text: "Highlighted"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; enabled: false } + Button { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; down: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; down: true; enabled: false } + + Button { text: "Hi-checked"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; enabled: false } + Button { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; down: true } + Button { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; down: true; enabled: false } + } + } + } + } + } + + ScrollIndicator.vertical: ScrollIndicator { } + } +} diff --git a/tests/manual/fonts/main.qml b/tests/manual/fonts/main.qml index 883226a7..089906ee 100644 --- a/tests/manual/fonts/main.qml +++ b/tests/manual/fonts/main.qml @@ -39,8 +39,8 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T import QtQuick.Layouts 1.2 ApplicationWindow { diff --git a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml index f4a51afb..3054fe22 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: busyIndicator.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-button.qml b/tests/manual/gifs/data/qtquickcontrols2-button.qml index 7ac9f81c..6cbcc42a 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-button.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-button.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: button.width diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml index df80a417..184ab339 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: column.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml index b280b385..98ce78a1 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: dial.implicitWidth + 20 diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml index 7ecda085..d5065f6d 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: dial.implicitWidth + 20 diff --git a/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml index 18bf942c..6aab7fc7 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: column.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-menu.qml b/tests/manual/gifs/data/qtquickcontrols2-menu.qml index 332e4d2b..60850a28 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-menu.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-menu.qml @@ -39,7 +39,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 // TODO: restore and finish https://codereview.qt-project.org/#/c/123948/ ApplicationWindow { diff --git a/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml index 60a0424f..77480ef0 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: column.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml b/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml index 4f764f8a..ece806d7 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: slider.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-slider.qml b/tests/manual/gifs/data/qtquickcontrols2-slider.qml index d109b1d2..412ce307 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-slider.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-slider.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: slider.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml index d019368e..7d6da848 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: swipeDelegate.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml index ecc7924e..74b69773 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: swipeDelegate.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml index 9dfee7f5..76c65e32 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: swipeDelegate.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-switch.qml b/tests/manual/gifs/data/qtquickcontrols2-switch.qml index 44d07e24..7bdaf102 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-switch.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-switch.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: 100 diff --git a/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml index a0ee4e03..e65890a1 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: column.implicitWidth diff --git a/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml b/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml index 3d0568e1..ff38277b 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Window { width: 300 diff --git a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml index e1139177..b610d099 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** 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. @@ -38,37 +38,35 @@ ** ****************************************************************************/ -import QtQuick 2.6 -import QtQuick.Window 2.0 -import QtQuick.Controls 2.0 +import QtQuick 2.8 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.1 Window { - width: 200 - height: 200 + width: frame.implicitWidth + 10 + height: frame.implicitHeight + 10 visible: true - Frame { - padding: 0 - anchors.centerIn: parent - width: row.implicitWidth - height: row.implicitHeight - - FontMetrics { - id: fontMetrics - } + function formatText(count, modelData) { + var data = count === 12 ? modelData + 1 : modelData; + return data.toString().length < 2 ? "0" + data : data; + } - Component { - id: delegateComponent + Component { + id: delegateComponent - Text { - text: modelData.toString().length < 2 ? "0" + modelData : modelData - color: "#666666" - opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: fontMetrics.font.pixelSize * 1.25 - } + Label { + text: formatText(Tumbler.tumbler.count, modelData) + opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } + } + + Frame { + id: frame + padding: 0 + anchors.centerIn: parent Row { id: row @@ -76,44 +74,20 @@ Window { Tumbler { id: hoursTumbler model: 12 - delegate: Text { - text: (modelData.toString().length < 2 ? "0" : "") + (modelData + 1) - color: "#666666" - opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: fontMetrics.font.pixelSize * 1.25 - } - width: 50 - height: 150 + delegate: delegateComponent } Tumbler { id: minutesTumbler - currentIndex: 6 model: 60 delegate: delegateComponent - width: 50 - height: 150 } Tumbler { id: amPmTumbler + wrap: false model: ["AM", "PM"] delegate: delegateComponent - width: 50 - height: 150 - contentItem: ListView { - anchors.fill: parent - model: amPmTumbler.model - delegate: amPmTumbler.delegate - - snapMode: ListView.SnapToItem - highlightRangeMode: ListView.StrictlyEnforceRange - preferredHighlightBegin: height / 2 - (height / 3 / 2) - preferredHighlightEnd: height / 2 + (height / 3 / 2) - clip: true - } } } } diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp index 1e3f141f..5a2ebdca 100644 --- a/tests/manual/gifs/gifrecorder.cpp +++ b/tests/manual/gifs/gifrecorder.cpp @@ -243,7 +243,7 @@ void GifRecorder::waitForFinish() if (mHighQuality) { // Indicate the end of recording and the beginning of conversion. QQmlComponent busyComponent(&mEngine); - busyComponent.setData("import QtQuick 2.6; import QtQuick.Controls 2.0; Rectangle { anchors.fill: parent; " \ + busyComponent.setData("import QtQuick 2.6; import QtQuick.Controls 2.1; Rectangle { anchors.fill: parent; " \ "BusyIndicator { width: 32; height: 32; anchors.centerIn: parent } }", QUrl()); QCOMPARE(busyComponent.status(), QQmlComponent::Ready); QQuickItem *busyRect = qobject_cast<QQuickItem*>(busyComponent.create()); diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index 078813e1..94400e04 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -128,7 +128,7 @@ void tst_Gifs::tumblerWrap() GifRecorder gifRecorder; gifRecorder.setDataDirPath(dataDirPath); gifRecorder.setOutputDir(outputDir); - gifRecorder.setRecordingDuration(4); + gifRecorder.setRecordingDuration(5); gifRecorder.setQmlFileName("qtquickcontrols2-tumbler-wrap.qml"); gifRecorder.start(); @@ -153,37 +153,40 @@ void tst_Gifs::tumblerWrap() QTest::mouseMove(window, QPoint(105, 158), 10); QTest::mouseMove(window, QPoint(105, 162), 13); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(105, 162), 0); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 130), 1098); - QTest::mouseMove(window, QPoint(154, 129), 50); - QTest::mouseMove(window, QPoint(153, 128), 0); - QTest::mouseMove(window, QPoint(153, 125), 16); - QTest::mouseMove(window, QPoint(152, 121), 0); - QTest::mouseMove(window, QPoint(152, 117), 17); - QTest::mouseMove(window, QPoint(151, 113), 0); - QTest::mouseMove(window, QPoint(151, 106), 16); - QTest::mouseMove(window, QPoint(150, 99), 1); - QTest::mouseMove(window, QPoint(148, 93), 16); - QTest::mouseMove(window, QPoint(148, 88), 0); - QTest::mouseMove(window, QPoint(148, 84), 17); - QTest::mouseMove(window, QPoint(147, 81), 0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 81), 0); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 74), 550); - QTest::mouseMove(window, QPoint(147, 75), 17); - QTest::mouseMove(window, QPoint(147, 76), 17); - QTest::mouseMove(window, QPoint(147, 80), 0); - QTest::mouseMove(window, QPoint(148, 85), 16); - QTest::mouseMove(window, QPoint(148, 92), 0); - QTest::mouseMove(window, QPoint(148, 103), 17); - QTest::mouseMove(window, QPoint(150, 119), 17); - QTest::mouseMove(window, QPoint(151, 138), 16); - QTest::mouseMove(window, QPoint(151, 145), 1); - QTest::mouseMove(window, QPoint(153, 151), 16); - QTest::mouseMove(window, QPoint(153, 157), 0); - QTest::mouseMove(window, QPoint(153, 163), 17); - QTest::mouseMove(window, QPoint(153, 167), 0); - QTest::mouseMove(window, QPoint(155, 171), 17); - QTest::mouseMove(window, QPoint(155, 175), 0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(155, 175), 0); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 100), 1098); + QTest::mouseMove(window, QPoint(154, 99), 16); + QTest::mouseMove(window, QPoint(153, 98), 16); + QTest::mouseMove(window, QPoint(153, 95), 16); + QTest::mouseMove(window, QPoint(152, 91), 15); + QTest::mouseMove(window, QPoint(152, 87), 14); + QTest::mouseMove(window, QPoint(151, 83), 13); + QTest::mouseMove(window, QPoint(151, 86), 13); + QTest::mouseMove(window, QPoint(150, 79), 12); + QTest::mouseMove(window, QPoint(148, 73), 12); + QTest::mouseMove(window, QPoint(148, 68), 12); + QTest::mouseMove(window, QPoint(148, 60), 10); + QTest::mouseMove(window, QPoint(147, 50), 10); + QTest::mouseMove(window, QPoint(147, 40), 9); + QTest::mouseMove(window, QPoint(147, 30), 8); + QTest::mouseMove(window, QPoint(147, 20), 7); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 20), 0); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 100), 1000); + QTest::mouseMove(window, QPoint(147, 101), 16); + QTest::mouseMove(window, QPoint(147, 102), 16); + QTest::mouseMove(window, QPoint(147, 105), 16); + QTest::mouseMove(window, QPoint(148, 109), 15); + QTest::mouseMove(window, QPoint(148, 115), 14); + QTest::mouseMove(window, QPoint(148, 120), 13); + QTest::mouseMove(window, QPoint(150, 125), 13); + QTest::mouseMove(window, QPoint(151, 130), 12); + QTest::mouseMove(window, QPoint(151, 135), 12); + QTest::mouseMove(window, QPoint(153, 140), 12); + QTest::mouseMove(window, QPoint(153, 150), 10); + QTest::mouseMove(window, QPoint(153, 160), 10); + QTest::mouseMove(window, QPoint(153, 170), 9); + QTest::mouseMove(window, QPoint(155, 180), 8); + QTest::mouseMove(window, QPoint(155, 188), 7); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(20, 188), 0); #endif gifRecorder.waitForFinish(); diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 9c843e7b..bbc1e881 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ + buttons \ gifs \ fonts \ styles \ diff --git a/tests/manual/styles/styles.qml b/tests/manual/styles/styles.qml index 277604eb..4655aec6 100644 --- a/tests/manual/styles/styles.qml +++ b/tests/manual/styles/styles.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ApplicationWindow { id: window diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 2fdc52af..dd1a1de8 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -41,9 +41,9 @@ import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Layouts 1.0 -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 -import QtQuick.Controls.Universal 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 +import QtQuick.Controls.Universal 2.1 ApplicationWindow { id: window @@ -97,6 +97,12 @@ ApplicationWindow { text: "Option 3" checkable: true } + + MenuSeparator {} + + MenuItem { + text: "Option A" + } } } ToolButton { @@ -128,6 +134,18 @@ ApplicationWindow { text: "Disabled" enabled: false } + + ToolSeparator {} + + ToolButton { + text: "1" + } + ToolButton { + text: "2" + } + + ToolSeparator {} + Item { Layout.fillWidth: true } diff --git a/tests/manual/viewinqwidget/main.qml b/tests/manual/viewinqwidget/main.qml index 5ad52d83..f90a6972 100644 --- a/tests/manual/viewinqwidget/main.qml +++ b/tests/manual/viewinqwidget/main.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.6 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Item { visible: true |