diff options
Diffstat (limited to 'tests/auto')
149 files changed, 4356 insertions, 269 deletions
diff --git a/tests/auto/accessibility/data/busyindicator.qml b/tests/auto/accessibility/data/busyindicator.qml index b15ea80a..5a1cf54a 100644 --- a/tests/auto/accessibility/data/busyindicator.qml +++ b/tests/auto/accessibility/data/busyindicator.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 BusyIndicator { } diff --git a/tests/auto/accessibility/data/button.qml b/tests/auto/accessibility/data/button.qml index 0fd14210..ecaba6cc 100644 --- a/tests/auto/accessibility/data/button.qml +++ b/tests/auto/accessibility/data/button.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Button { text: "Button" diff --git a/tests/auto/accessibility/data/checkbox.qml b/tests/auto/accessibility/data/checkbox.qml index e70d7d83..cb46c074 100644 --- a/tests/auto/accessibility/data/checkbox.qml +++ b/tests/auto/accessibility/data/checkbox.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 CheckBox { text: "CheckBox" diff --git a/tests/auto/accessibility/data/checkdelegate.qml b/tests/auto/accessibility/data/checkdelegate.qml index 0a1a4a4f..f911caf0 100644 --- a/tests/auto/accessibility/data/checkdelegate.qml +++ b/tests/auto/accessibility/data/checkdelegate.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 CheckDelegate { text: "CheckDelegate" diff --git a/tests/auto/accessibility/data/combobox.qml b/tests/auto/accessibility/data/combobox.qml index 42e4d47b..52931968 100644 --- a/tests/auto/accessibility/data/combobox.qml +++ b/tests/auto/accessibility/data/combobox.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ComboBox { model: ["ComboBox"] diff --git a/tests/auto/accessibility/data/control.qml b/tests/auto/accessibility/data/control.qml index 4831a6c6..a8fd0613 100644 --- a/tests/auto/accessibility/data/control.qml +++ b/tests/auto/accessibility/data/control.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Control { } diff --git a/tests/auto/accessibility/data/dial.qml b/tests/auto/accessibility/data/dial.qml index 39b85550..354ccdbd 100644 --- a/tests/auto/accessibility/data/dial.qml +++ b/tests/auto/accessibility/data/dial.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Dial { } diff --git a/tests/auto/accessibility/data/dialog.qml b/tests/auto/accessibility/data/dialog.qml new file mode 100644 index 00000000..26e944fd --- /dev/null +++ b/tests/auto/accessibility/data/dialog.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.1 + +Dialog { + title: "Dialog" +} diff --git a/tests/auto/accessibility/data/frame.qml b/tests/auto/accessibility/data/frame.qml index 6fcbab23..6a2ec40e 100644 --- a/tests/auto/accessibility/data/frame.qml +++ b/tests/auto/accessibility/data/frame.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Frame { } diff --git a/tests/auto/accessibility/data/groupbox.qml b/tests/auto/accessibility/data/groupbox.qml index c48b4847..ebb3cf7d 100644 --- a/tests/auto/accessibility/data/groupbox.qml +++ b/tests/auto/accessibility/data/groupbox.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 GroupBox { title: "GroupBox" diff --git a/tests/auto/accessibility/data/itemdelegate.qml b/tests/auto/accessibility/data/itemdelegate.qml index 9b647315..91e1d910 100644 --- a/tests/auto/accessibility/data/itemdelegate.qml +++ b/tests/auto/accessibility/data/itemdelegate.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ItemDelegate { text: "ItemDelegate" diff --git a/tests/auto/accessibility/data/label.qml b/tests/auto/accessibility/data/label.qml index bb87a4e9..e799f8de 100644 --- a/tests/auto/accessibility/data/label.qml +++ b/tests/auto/accessibility/data/label.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Label { text: "Label" diff --git a/tests/auto/accessibility/data/menu.qml b/tests/auto/accessibility/data/menu.qml index def3020b..b931644a 100644 --- a/tests/auto/accessibility/data/menu.qml +++ b/tests/auto/accessibility/data/menu.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Menu { } diff --git a/tests/auto/accessibility/data/menuitem.qml b/tests/auto/accessibility/data/menuitem.qml index 70c2ff33..308c1c2b 100644 --- a/tests/auto/accessibility/data/menuitem.qml +++ b/tests/auto/accessibility/data/menuitem.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 MenuItem { text: "MenuItem" diff --git a/tests/auto/accessibility/data/page.qml b/tests/auto/accessibility/data/page.qml index 59139855..cda7b80b 100644 --- a/tests/auto/accessibility/data/page.qml +++ b/tests/auto/accessibility/data/page.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Page { title: "Page" diff --git a/tests/auto/accessibility/data/pageindicator.qml b/tests/auto/accessibility/data/pageindicator.qml index bb69a27a..a882296e 100644 --- a/tests/auto/accessibility/data/pageindicator.qml +++ b/tests/auto/accessibility/data/pageindicator.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 PageIndicator { } diff --git a/tests/auto/accessibility/data/pane.qml b/tests/auto/accessibility/data/pane.qml index 1de210ec..24856e26 100644 --- a/tests/auto/accessibility/data/pane.qml +++ b/tests/auto/accessibility/data/pane.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Pane { } diff --git a/tests/auto/accessibility/data/popup.qml b/tests/auto/accessibility/data/popup.qml index 05e968e5..e1d9f8ff 100644 --- a/tests/auto/accessibility/data/popup.qml +++ b/tests/auto/accessibility/data/popup.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Popup { } diff --git a/tests/auto/accessibility/data/progressbar.qml b/tests/auto/accessibility/data/progressbar.qml index 5e9b11f1..c8733d5d 100644 --- a/tests/auto/accessibility/data/progressbar.qml +++ b/tests/auto/accessibility/data/progressbar.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ProgressBar { from: 0 diff --git a/tests/auto/accessibility/data/radiobutton.qml b/tests/auto/accessibility/data/radiobutton.qml index 58bdf225..1ca431f5 100644 --- a/tests/auto/accessibility/data/radiobutton.qml +++ b/tests/auto/accessibility/data/radiobutton.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 RadioButton { text: "RadioButton" diff --git a/tests/auto/accessibility/data/rangeslider.qml b/tests/auto/accessibility/data/rangeslider.qml index 45b1d4ae..76736fb8 100644 --- a/tests/auto/accessibility/data/rangeslider.qml +++ b/tests/auto/accessibility/data/rangeslider.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 RangeSlider { from: 0 diff --git a/tests/auto/accessibility/data/roundbutton.qml b/tests/auto/accessibility/data/roundbutton.qml new file mode 100644 index 00000000..8edf58de --- /dev/null +++ b/tests/auto/accessibility/data/roundbutton.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.1 + +RoundButton { + text: "RoundButton" +} diff --git a/tests/auto/accessibility/data/scrollbar.qml b/tests/auto/accessibility/data/scrollbar.qml index f0598b4b..1420ed19 100644 --- a/tests/auto/accessibility/data/scrollbar.qml +++ b/tests/auto/accessibility/data/scrollbar.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ScrollBar { } diff --git a/tests/auto/accessibility/data/scrollindicator.qml b/tests/auto/accessibility/data/scrollindicator.qml index 4cb81c4e..34e429ad 100644 --- a/tests/auto/accessibility/data/scrollindicator.qml +++ b/tests/auto/accessibility/data/scrollindicator.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ScrollIndicator { } diff --git a/tests/auto/accessibility/data/slider.qml b/tests/auto/accessibility/data/slider.qml index 775ce7d0..088bd23a 100644 --- a/tests/auto/accessibility/data/slider.qml +++ b/tests/auto/accessibility/data/slider.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Slider { from: 0 diff --git a/tests/auto/accessibility/data/spinbox.qml b/tests/auto/accessibility/data/spinbox.qml index 029cbc65..07e2a54e 100644 --- a/tests/auto/accessibility/data/spinbox.qml +++ b/tests/auto/accessibility/data/spinbox.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 SpinBox { from: 0 diff --git a/tests/auto/accessibility/data/switch.qml b/tests/auto/accessibility/data/switch.qml index 8bb43893..0678f113 100644 --- a/tests/auto/accessibility/data/switch.qml +++ b/tests/auto/accessibility/data/switch.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 Switch { text: "Switch" diff --git a/tests/auto/accessibility/data/switchdelegate.qml b/tests/auto/accessibility/data/switchdelegate.qml index 9f2324c0..fba0c321 100644 --- a/tests/auto/accessibility/data/switchdelegate.qml +++ b/tests/auto/accessibility/data/switchdelegate.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 SwitchDelegate { text: "SwitchDelegate" diff --git a/tests/auto/accessibility/data/tabbar.qml b/tests/auto/accessibility/data/tabbar.qml index 4b1f73a1..209a094f 100644 --- a/tests/auto/accessibility/data/tabbar.qml +++ b/tests/auto/accessibility/data/tabbar.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TabBar { } diff --git a/tests/auto/accessibility/data/tabbutton.qml b/tests/auto/accessibility/data/tabbutton.qml index 6b979bc8..c76e9048 100644 --- a/tests/auto/accessibility/data/tabbutton.qml +++ b/tests/auto/accessibility/data/tabbutton.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TabButton { text: "TabButton" diff --git a/tests/auto/accessibility/data/textarea.qml b/tests/auto/accessibility/data/textarea.qml index 93b5b220..1ffe366f 100644 --- a/tests/auto/accessibility/data/textarea.qml +++ b/tests/auto/accessibility/data/textarea.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TextArea { text: "TextArea" diff --git a/tests/auto/accessibility/data/textfield.qml b/tests/auto/accessibility/data/textfield.qml index 06ba1a58..f87957eb 100644 --- a/tests/auto/accessibility/data/textfield.qml +++ b/tests/auto/accessibility/data/textfield.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 TextField { text: "TextField" diff --git a/tests/auto/accessibility/data/toolbar.qml b/tests/auto/accessibility/data/toolbar.qml index 7b3ba07f..e1887de4 100644 --- a/tests/auto/accessibility/data/toolbar.qml +++ b/tests/auto/accessibility/data/toolbar.qml @@ -1,4 +1,4 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ToolBar { } diff --git a/tests/auto/accessibility/data/toolbutton.qml b/tests/auto/accessibility/data/toolbutton.qml index 79f155ec..e088bb56 100644 --- a/tests/auto/accessibility/data/toolbutton.qml +++ b/tests/auto/accessibility/data/toolbutton.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ToolButton { text: "ToolButton" diff --git a/tests/auto/accessibility/data/tooltip.qml b/tests/auto/accessibility/data/tooltip.qml index 1d1bae28..dcb5b3b9 100644 --- a/tests/auto/accessibility/data/tooltip.qml +++ b/tests/auto/accessibility/data/tooltip.qml @@ -1,5 +1,5 @@ import QtQuick 2.5 -import QtQuick.Controls 2.0 +import QtQuick.Controls 2.1 ToolTip { text: "ToolTip" diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 99f6391e..b4286aad 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -73,6 +73,7 @@ void tst_accessibility::a11y_data() QTest::newRow("Container") << "container" << 0x00000000 << ""; //QAccessible::NoRole QTest::newRow("Control") << "control" << 0x00000000 << ""; //QAccessible::NoRole QTest::newRow("Dial") << "dial" << 0x00000031 << ""; //QAccessible::Dial + QTest::newRow("Dialog") << "dialog" << 0x00000012 << "Dialog"; //QAccessible::Dialog QTest::newRow("Drawer") << "drawer" << 0x00000012 << ""; //QAccessible::Dialog QTest::newRow("Frame") << "frame" << 0x00000013 << ""; //QAccessible::Border QTest::newRow("GroupBox") << "groupbox" << 0x00000014 << "GroupBox"; //QAccessible::Grouping @@ -88,6 +89,7 @@ void tst_accessibility::a11y_data() QTest::newRow("RadioButton") << "radiobutton" << 0x0000002D << "RadioButton"; //QAccessible::RadioButton QTest::newRow("RadioDelegate") << "radiodelegate" << 0x0000002D << "RadioDelegate"; //QAccessible::RadioButton QTest::newRow("RangeSlider") << "rangeslider" << 0x00000033 << ""; //QAccessible::Slider + QTest::newRow("RoundButton") << "roundbutton" << 0x0000002B << "RoundButton"; //QAccessible::Button QTest::newRow("ScrollBar") << "scrollbar" << 0x00000003 << ""; //QAccessible::ScrollBar QTest::newRow("ScrollIndicator") << "scrollindicator" << 0x00000027 << ""; //QAccessible::Indicator QTest::newRow("Slider") << "slider" << 0x00000033 << ""; //QAccessible::Slider 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 2f91f664..fb7f96b8 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 ba5ee94c..27fc4525 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 1de43426..16d1bb94 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 @@ -213,8 +213,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 }], @@ -229,8 +232,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 754e4f0b..186eb9d1 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 @@ -196,6 +196,32 @@ TestCase { group.destroy() } + function test_clicked() { + var group = buttonGroup.createObject(testCase) + verify(group) + + var clickedSpy = signalSpy.createObject(testCase, {target: group, signalName: "clicked"}) + 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 607de2e8..2ba9be8f 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 @@ -76,6 +76,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_container.qml b/tests/auto/controls/data/tst_container.qml index d1ff54e0..3c7032c7 100644 --- a/tests/auto/controls/data/tst_container.qml +++ b/tests/auto/controls/data/tst_container.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_control.qml b/tests/auto/controls/data/tst_control.qml index 3018498e..1b60eb73 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 @@ -859,7 +859,9 @@ TestCase { verify(control) compare(control.hovered, false) - compare(control.hoverEnabled, false) + compare(control.hoverEnabled, Qt.styleHints.useHoverEffects) + + control.hoverEnabled = false mouseMove(control, control.width / 2, control.height / 2) compare(control.hovered, false) @@ -891,6 +893,42 @@ TestCase { control.destroy() } + function test_hoverEnabled() { + var control = component.createObject(testCase) + compare(control.hoverEnabled, Qt.styleHints.useHoverEffects) + + var child = component.createObject(control) + var grandChild = component.createObject(child) + + var childExplicitHoverEnabled = component.createObject(control, {hoverEnabled: true}) + var grandChildExplicitHoverDisabled = component.createObject(childExplicitHoverEnabled, {hoverEnabled: false}) + + var childExplicitHoverDisabled = component.createObject(control, {hoverEnabled: false}) + var grandChildExplicitHoverEnabled = component.createObject(childExplicitHoverDisabled, {hoverEnabled: true}) + + control.hoverEnabled = false + compare(control.hoverEnabled, false) + compare(grandChild.hoverEnabled, false) + + compare(childExplicitHoverEnabled.hoverEnabled, true) + compare(grandChildExplicitHoverDisabled.hoverEnabled, false) + + compare(childExplicitHoverDisabled.hoverEnabled, false) + compare(grandChildExplicitHoverEnabled.hoverEnabled, true) + + control.hoverEnabled = true + compare(control.hoverEnabled, true) + compare(grandChild.hoverEnabled, true) + + compare(childExplicitHoverEnabled.hoverEnabled, true) + compare(grandChildExplicitHoverDisabled.hoverEnabled, false) + + compare(childExplicitHoverDisabled.hoverEnabled, false) + compare(grandChildExplicitHoverEnabled.hoverEnabled, true) + + control.destroy() + } + function test_implicitSize() { var control = component.createObject(testCase) verify(control) 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..69c47fed --- /dev/null +++ b/tests/auto/controls/data/tst_dialog.qml @@ -0,0 +1,302 @@ +/**************************************************************************** +** +** 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: signalSpy + SignalSpy { } + } + + function test_defaults() { + var control = dialog.createObject(testCase) + verify(control) + verify(control.header) + verify(control.footer) + 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" }, + { tag: "custom", custom: true } + ] + } + + function test_buttonBox(data) { + var control = dialog.createObject(testCase) + + if (data.custom) + control.footer = buttonBox.createObject(testCase) + control.standardButtons = Dialog.Ok | Dialog.Cancel + var box = control.footer + 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_layout() { + var control = dialog.createObject(testCase, {width: 100, height: 100}) + verify(control) + + control.open() + waitForRendering(control.contentItem) + verify(control.visible) + + compare(control.width, 100) + compare(control.height, 100) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight) + + control.header = buttonBox.createObject(control.contentItem) + compare(control.header.width, control.width) + verify(control.header.height > 0) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight - control.header.height) + + control.footer = buttonBox.createObject(control.contentItem) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight - control.header.height - control.footer.height) + + control.topPadding = 9 + control.leftPadding = 2 + control.rightPadding = 6 + control.bottomPadding = 7 + + compare(control.header.x, 0) + compare(control.header.y, 0) + compare(control.header.width, control.width) + verify(control.header.height > 0) + + compare(control.footer.x, 0) + compare(control.footer.y, control.height - control.footer.height) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding + control.header.height) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight - control.header.height - control.footer.height) + + control.header.visible = false + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight - control.footer.height) + + control.footer.visible = false + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight) + + control.contentItem.implicitWidth = 50 + control.contentItem.implicitHeight = 60 + compare(control.implicitWidth, control.contentItem.implicitWidth + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding) + + control.header.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight) + + control.footer.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight + control.footer.implicitHeight) + + control.header.implicitWidth = 150 + compare(control.implicitWidth, control.header.implicitWidth) + + control.footer.implicitWidth = 160 + compare(control.implicitWidth, control.footer.implicitWidth) + + control.destroy() + } + + function test_spacing_data() { + return [ + { tag: "content", header: false, content: true, footer: false }, + { tag: "header,content", header: true, content: true, footer: false }, + { tag: "content,footer", header: false, content: true, footer: true }, + { tag: "header,content,footer", header: true, content: true, footer: true }, + { tag: "header,footer", header: true, content: false, footer: true }, + { tag: "header", header: true, content: false, footer: false }, + { tag: "footer", header: false, content: false, footer: true }, + ] + } + + function test_spacing(data) { + var control = dialog.createObject(testCase, {spacing: 20, width: 100, height: 100}) + verify(control) + + control.open() + waitForRendering(control.contentItem) + verify(control.visible) + + control.contentItem.visible = data.content + control.header = buttonBox.createObject(control.contentItem, {visible: data.header}) + control.footer = buttonBox.createObject(control.contentItem, {visible: data.footer}) + + compare(control.header.x, 0) + compare(control.header.y, 0) + compare(control.header.width, control.width) + verify(control.header.height > 0) + + compare(control.footer.x, 0) + compare(control.footer.y, control.height - control.footer.height) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0)) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight + - (data.header ? control.header.height + control.spacing : 0) + - (data.footer ? control.footer.height + control.spacing : 0)) + + 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 021afdb2..2e1f32dc 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..9b52236e 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 @@ -56,6 +56,40 @@ TestCase { } Component { + id: oneChildPage + Page { + Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + + Component { + id: twoChildrenPage + Page { + Item { + implicitWidth: 100 + implicitHeight: 30 + } + Item { + implicitWidth: 200 + implicitHeight: 60 + } + } + } + + Component { + id: contentPage + Page { + contentItem: Item { + implicitWidth: 100 + implicitHeight: 30 + } + } + } + + Component { id: toolBar ToolBar { } } @@ -71,6 +105,53 @@ TestCase { control.destroy() } + function test_empty() { + var control = page.createObject(testCase) + verify(control) + + verify(control.contentItem) + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + + control.destroy() + } + + function test_oneChild() { + var control = oneChildPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) + + control.destroy() + } + + function test_twoChildren() { + var control = twoChildrenPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 0) + compare(control.contentHeight, 0) + compare(control.implicitWidth, control.leftPadding + control.rightPadding) + compare(control.implicitHeight, control.topPadding + control.bottomPadding) + + control.destroy() + } + + function test_contentItem() { + var control = contentPage.createObject(testCase) + verify(control) + + compare(control.contentWidth, 100) + compare(control.contentHeight, 30) + compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding) + + control.destroy() + } + function test_layout() { var control = page.createObject(testCase, {width: 100, height: 100}) verify(control) @@ -124,6 +205,65 @@ TestCase { compare(control.contentItem.width, control.availableWidth) compare(control.contentItem.height, control.availableHeight) + control.contentItem.implicitWidth = 50 + control.contentItem.implicitHeight = 60 + compare(control.implicitWidth, control.contentItem.implicitWidth + control.leftPadding + control.rightPadding) + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding) + + control.header.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight + control.spacing) + + control.footer.visible = true + compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding + + control.header.implicitHeight + control.footer.implicitHeight + 2 * control.spacing) + + control.header.implicitWidth = 150 + compare(control.implicitWidth, control.header.implicitWidth + control.leftPadding + control.rightPadding) + + control.footer.implicitWidth = 160 + compare(control.implicitWidth, control.footer.implicitWidth + control.leftPadding + control.rightPadding) + + control.destroy() + } + + function test_spacing_data() { + return [ + { tag: "content", header: false, content: true, footer: false }, + { tag: "header,content", header: true, content: true, footer: false }, + { tag: "content,footer", header: false, content: true, footer: true }, + { tag: "header,content,footer", header: true, content: true, footer: true }, + { tag: "header,footer", header: true, content: false, footer: true }, + { tag: "header", header: true, content: false, footer: false }, + { tag: "footer", header: false, content: false, footer: true }, + ] + } + + function test_spacing(data) { + var control = page.createObject(testCase, {spacing: 20, width: 100, height: 100}) + verify(control) + + control.contentItem.visible = data.content + control.header = toolBar.createObject(control.contentItem, {visible: data.header}) + control.footer = toolBar.createObject(control.contentItem, {visible: data.footer}) + + compare(control.header.x, 0) + compare(control.header.y, 0) + compare(control.header.width, control.width) + verify(control.header.height > 0) + + compare(control.footer.x, 0) + compare(control.footer.y, control.height - control.footer.height) + compare(control.footer.width, control.width) + verify(control.footer.height > 0) + + compare(control.contentItem.x, control.leftPadding) + compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0)) + compare(control.contentItem.width, control.availableWidth) + compare(control.contentItem.height, control.availableHeight + - (data.header ? control.header.height + control.spacing : 0) + - (data.footer ? control.footer.height + control.spacing : 0)) + control.destroy() } } 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 0ca8ce57..982ac7ab 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" 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 3167be0b..eb654bbc 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 @@ -675,4 +675,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_roundbutton.qml b/tests/auto/controls/data/tst_roundbutton.qml new file mode 100644 index 00000000..aa956776 --- /dev/null +++ b/tests/auto/controls/data/tst_roundbutton.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtQuick.Controls 2.1 + +TestCase { + id: testCase + width: 200 + height: 200 + visible: true + when: windowShown + name: "RoundButton" + + Component { + id: roundButton + RoundButton { } + } + + function test_radius() { + var control = roundButton.createObject(testCase); + verify(control); + + var implicitRadius = control.radius; + compare(implicitRadius, Math.min(control.width, control.height) / 2); + + control.radius = 10; + compare(control.radius, 10); + + control.radius = undefined; + compare(control.radius, implicitRadius); + + control.width = -1; + compare(control.radius, 0); + + control.width = 10; + compare(control.radius, 5); + + control.destroy(); + } +} diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml index 7c83cca9..54ecf15f 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 @@ -97,6 +97,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) @@ -118,6 +125,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 @@ -315,4 +329,28 @@ TestCase { container.destroy() } + + function test_hover_data() { + return [ + { tag: "enabled", hoverEnabled: true }, + { tag: "disabled", hoverEnabled: false }, + ] + } + + function test_hover(data) { + var control = scrollBar.createObject(testCase, {hoverEnabled: data.hoverEnabled}) + verify(control) + + compare(control.hovered, false) + + mouseMove(control) + compare(control.hovered, data.hoverEnabled) + compare(control.active, data.hoverEnabled) + + mouseMove(control, -1, -1) + compare(control.hovered, false) + compare(control.active, false) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml index f5e57e2d..1ec03b15 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 4a698076..029aff14 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 @@ -520,4 +520,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 a62128d2..30db246f 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 @@ -460,6 +460,35 @@ 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() + } + function test_valueFromText_data() { return [ { tag: "editable", editable: true }, diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 28a22306..b0e18389 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 @@ -567,29 +567,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, 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, 1) - compare(control.pushExitRuns, 1) + 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() } @@ -644,6 +675,60 @@ TestCase { } Component { + id: removeComponent + + Item { + objectName: "removeItem" + StackView.onRemoved: destroy() + } + } + + function test_destroyOnRemoved() { + var control = stackView.createObject(testCase, { initialItem: component }) + verify(control) + + var item = removeComponent.createObject(control) + verify(item) + + var removedSpy = signalSpy.createObject(control, { target: item.StackView, signalName: "removed" }) + verify(removedSpy) + verify(removedSpy.valid) + + var destructionSpy = signalSpy.createObject(control, { target: item.Component, signalName: "destruction" }) + verify(destructionSpy) + verify(destructionSpy.valid) + + // push-pop + control.push(item, StackView.Immediate) + compare(control.currentItem, item) + control.pop(StackView.Transition) + item = null + tryCompare(removedSpy, "count", 1) + tryCompare(destructionSpy, "count", 1) + compare(control.busy, false) + + item = removeComponent.createObject(control) + verify(item) + + removedSpy.target = item.StackView + verify(removedSpy.valid) + + destructionSpy.target = item.Component + verify(destructionSpy.valid) + + // push-replace + control.push(item, StackView.Immediate) + compare(control.currentItem, item) + control.replace(component, StackView.Transition) + item = null + tryCompare(removedSpy, "count", 2) + tryCompare(destructionSpy, "count", 2) + compare(control.busy, false) + + control.destroy() + } + + Component { id: attachedItem Item { property int index: StackView.index @@ -831,11 +916,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() @@ -862,6 +947,62 @@ 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() + } + // QTBUG-56158 function test_repeatedPop() { var control = stackView.createObject(testCase, {initialItem: component, width: testCase.width, height: testCase.height}) diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 21bb1a37..bcf25f28 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 @@ -110,14 +111,14 @@ TestCase { function test_horizontalAnchors_data() { return [ - { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":58:25" }, - { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":65:25" }, - { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":72:25" }, - { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":79:25" }, - { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":86:26" }, - { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":93:26" }, - { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":100:26" }, - { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":107:26" } + { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":59:25" }, + { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":66:25" }, + { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":73:25" }, + { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":80:25" }, + { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":87:26" }, + { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":94:26" }, + { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":101:26" }, + { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":108:26" } ]; } @@ -166,6 +167,12 @@ TestCase { } Component { + id: signalSpyComponent + + SignalSpy {} + } + + Component { id: itemComponent Item {} @@ -201,7 +208,7 @@ TestCase { verify(control); ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; // Shouldn't be any warnings when unsetting delegates. @@ -210,7 +217,7 @@ TestCase { // right is still set. ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; control.swipe.right = null; @@ -219,11 +226,11 @@ TestCase { control.swipe.behind = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.left = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.right = itemComponent; control.swipe.behind = null; @@ -238,7 +245,7 @@ TestCase { var oldLeft = control.swipe.left; var oldLeftItem = control.swipe.leftItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":160: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); @@ -249,7 +256,7 @@ TestCase { var oldRight = control.swipe.right; var oldRightItem = control.swipe.rightItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":160: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); @@ -275,7 +282,7 @@ TestCase { var oldBehind = control.swipe.behind; var oldBehindItem = control.swipe.behindItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":160: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); @@ -297,7 +304,7 @@ TestCase { SignalSequenceSpy { id: mouseSignalSequenceSpy - signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged"] + signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "pressAndHold"] } function test_swipe() { @@ -306,12 +313,17 @@ TestCase { var overDragDistance = Math.round(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); @@ -321,6 +333,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); @@ -332,6 +345,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); @@ -344,6 +358,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); @@ -356,6 +371,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); @@ -366,6 +382,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); @@ -381,11 +398,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"]; @@ -393,6 +412,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); @@ -402,11 +422,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"]; @@ -414,6 +436,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); @@ -507,12 +530,6 @@ TestCase { } } - Component { - id: signalSpyComponent - - SignalSpy {} - } - function test_eventsToLeftAndRight() { var control = swipeDelegateWithButtonComponent.createObject(testCase); verify(control); @@ -607,6 +624,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(); } @@ -629,8 +666,6 @@ TestCase { text: modelData width: listView.width - onClicked: if (swipe.complete) ListView.view.model.remove(index) - property alias removeAnimation: onRemoveAnimation ListView.onRemove: SequentialAnimation { @@ -655,9 +690,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" @@ -680,11 +718,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); @@ -695,9 +736,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 @@ -992,6 +1047,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. diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index 3afcdf16..2d5f413a 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 @@ -103,6 +103,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() } @@ -404,6 +414,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 } } @@ -424,11 +436,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) @@ -445,6 +461,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() @@ -489,12 +507,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); @@ -502,6 +524,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); @@ -509,6 +533,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 93773e0d..f3843cf7 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 8bc0e4c3..4a5d711f 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 9268f765..da0181a1 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 @@ -134,6 +134,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 959662ee..5dc93287 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 @@ -164,6 +164,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 73431ca6..a59cff07 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 c78a7770..d9c95dbf 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 2e0e3295..b3230ca4 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 @@ -58,6 +58,16 @@ 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 + } + } Component { id: itemComponent @@ -85,6 +95,16 @@ TestCase { wait(0) } + function createTumbler(args) { + if (args === undefined) + tumbler = tumblerComponent.createObject(cleanupItem); + else + tumbler = tumblerComponent.createObject(cleanupItem, args); + verify(tumbler, "Tumbler: failed to create an instance"); + tumblerView = findView(tumbler); + verify(tumblerView); + } + function tumblerXCenter() { return tumbler.leftPadding + tumbler.width / 2; } @@ -95,26 +115,46 @@ 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); } } - Component { - id: tumblerComponent + 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() { + createTumbler(); + verify(tumbler.wrap); - Tumbler {} + tumbler.delegate = noAttachedPropertiesDelegate; + // Shouldn't assert. + tumbler.wrap = false; + verify(findView(tumbler)); } // TODO: test that currentIndex is maintained between contentItem changes... @@ -122,8 +162,7 @@ TestCase { // } function test_currentIndex() { - tumbler = tumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); compare(tumbler.contentItem.parent, tumbler); tumbler.model = 5; @@ -133,75 +172,193 @@ 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); } - function test_keyboardNavigation() { - tumbler = tumblerComponent.createObject(cleanupItem); + 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 + tumbler = data.component.createObject(cleanupItem); 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); + } + } + + function test_keyboardNavigation() { + createTumbler(); 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 = tumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); 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 = cleanupItem.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 = cleanupItem.mapFromItem(firstItem, 0, 0); @@ -209,12 +366,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); @@ -241,18 +398,18 @@ TestCase { tumbler = component.createObject(cleanupItem); // 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; @@ -361,27 +518,106 @@ TestCase { } function test_displacement(data) { - tumbler = tumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); // 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() { + createTumbler(); + + 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: twoItemTumbler + + Tumbler { + model: 2 + } + } + + Component { + id: tenItemTumbler + + Tumbler { + model: 10 + } + } + + function test_countWrap() { + tumbler = tumblerComponent.createObject(cleanupItem); + verify(tumbler); + + // 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(cleanupItem); + 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); + } + + function test_explicitlyWrapping() { + // Check that explicitly setting wrap to true works even when it was implicitly true. + var explicitlyWrapping = tenItemTumbler.createObject(cleanupItem); + 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); + } + Component { - id: listViewTumblerComponent - //! [contentItem] + id: customListViewTumblerComponent + Tumbler { id: listViewTumbler @@ -397,7 +633,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(cleanupItem); + // 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); + } + + function test_customContentItemAfterConstruction_data() { + return [ + { tag: "ListView", componentPath: "TumblerListView.qml" }, + { tag: "PathView", componentPath: "TumblerPathView.qml" } + ]; + } + + function test_customContentItemAfterConstruction(data) { + createTumbler(); + + 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() { @@ -438,20 +762,18 @@ TestCase { } function test_displacementListView(data) { - // Sanity check that they're aren't any children at this stage. - tryCompare(cleanupItem.children, "length", 0); - - tumbler = listViewTumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); + 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 @@ -511,16 +833,17 @@ TestCase { } function test_listViewFlickAboveBounds(data) { - tumbler = listViewTumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); + 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. @@ -577,8 +900,7 @@ TestCase { } function test_visibleItemCount(data) { - tumbler = tumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); tumbler.delegate = objectNameDelegate; tumbler.visibleItemCount = data.visibleItemCount; @@ -588,9 +910,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); } } @@ -604,12 +926,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() { tumbler = tumblerComponent.createObject(cleanupItem); verify(tumbler); @@ -621,19 +937,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(cleanupItem); verify(object); - 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(cleanupItem); - object = simpleDisplacementDelegate.createObject(gridView); - verify(object); - object.destroy(); } property Component paddingDelegate: Text { @@ -680,8 +989,7 @@ TestCase { } function test_padding(data) { - tumbler = tumblerComponent.createObject(cleanupItem); - verify(tumbler); + createTumbler(); tumbler.delegate = paddingDelegate; tumbler.model = 5; @@ -733,8 +1041,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 9032ea0d..0aa4b34e 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/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 830f63b0..a523beed 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -452,6 +452,10 @@ void tst_Drawer::hover() QVERIFY(drawer); drawer->setModal(modal); + QQuickControl *drawerItem = qobject_cast<QQuickControl *>(drawer->popupItem()); + QVERIFY(drawerItem); + QVERIFY(drawerItem->isHoverEnabled()); + QQuickButton *backgroundButton = window->property("backgroundButton").value<QQuickButton*>(); QVERIFY(backgroundButton); backgroundButton->setHoverEnabled(true); @@ -469,16 +473,19 @@ void tst_Drawer::hover() QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); QCOMPARE(backgroundButton->isHovered(), !modal); QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); // hover the drawer background QTest::mouseMove(window, QPoint(1, 1)); QVERIFY(!backgroundButton->isHovered()); QVERIFY(!drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); // hover the button in a drawer QTest::mouseMove(window, QPoint(2, 2)); QVERIFY(!backgroundButton->isHovered()); QVERIFY(drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); QSignalSpy closedSpy(drawer, SIGNAL(closed())); QVERIFY(closedSpy.isValid()); @@ -488,6 +495,8 @@ void tst_Drawer::hover() // hover the background button after closing the drawer QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); QVERIFY(backgroundButton->isHovered()); + QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); } void tst_Drawer::wheel_data() @@ -739,7 +748,7 @@ void tst_Drawer::touch() QTest::touchEvent(window, device.data()).move(0, QPoint(300 - drawer->dragMargin(), 100)); for (int x = 300; x > 100; x -= 10) { QTest::touchEvent(window, device.data()).move(0, QPoint(x, 100)); - QQuickWindowPrivate::get(window)->flushDelayedTouchEvent(); + QQuickWindowPrivate::get(window)->flushFrameSynchronousEvents(); } QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100)); QTRY_COMPARE(drawer->position(), 0.5); 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 3f3b1ae5..409f2fc7 100644 --- a/tests/auto/focus/tst_focus.cpp +++ b/tests/auto/focus/tst_focus.cpp @@ -126,7 +126,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); @@ -209,7 +209,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 7617cfcc..0635ad81 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")); + QQuickWindow *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_standardpaths.qml b/tests/auto/platform/data/tst_standardpaths.qml new file mode 100644 index 00000000..3b8dde3e --- /dev/null +++ b/tests/auto/platform/data/tst_standardpaths.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 + name: "StandardPaths" + + function test_standardLocation() { + // Q_ENUMS(QStandardPaths::StandardLocation) + compare(StandardPaths.DesktopLocation, 0) + compare(StandardPaths.DocumentsLocation, 1) + compare(StandardPaths.FontsLocation, 2) + compare(StandardPaths.ApplicationsLocation, 3) + compare(StandardPaths.MusicLocation, 4) + compare(StandardPaths.MoviesLocation, 5) + compare(StandardPaths.PicturesLocation, 6) + compare(StandardPaths.TempLocation, 7) + compare(StandardPaths.HomeLocation, 8) + compare(StandardPaths.DataLocation, 9) + compare(StandardPaths.CacheLocation, 10) + compare(StandardPaths.GenericDataLocation, 11) + compare(StandardPaths.RuntimeLocation, 12) + compare(StandardPaths.ConfigLocation, 13) + compare(StandardPaths.DownloadLocation, 14) + compare(StandardPaths.GenericCacheLocation, 15) + compare(StandardPaths.GenericConfigLocation, 16) + compare(StandardPaths.AppDataLocation, 17) + compare(StandardPaths.AppConfigLocation, 18) + compare(StandardPaths.AppLocalDataLocation, StandardPaths.DataLocation) + } + + function test_locateOptions() { + // Q_ENUMS(QStandardPaths::LocateOptions) + compare(StandardPaths.LocateFile, 0) + compare(StandardPaths.LocateDirectory, 1) + } +} 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 e1e100d7..9985997b 100644 --- a/tests/auto/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml @@ -41,9 +41,9 @@ import QtQuick 2.2 import QtQuick.Window 2.2 import QtTest 1.0 -import QtQuick.Templates 2.0 as T -import QtQuick.Controls 2.0 -import QtQuick.Controls.Material 2.0 +import QtQuick.Templates 2.1 as T +import QtQuick.Controls 2.1 +import QtQuick.Controls.Material 2.1 TestCase { id: testCase @@ -596,7 +596,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/qquickstyle.pro b/tests/auto/qquickstyle/qquickstyle.pro index b6173c1b..5514685a 100644 --- a/tests/auto/qquickstyle/qquickstyle.pro +++ b/tests/auto/qquickstyle/qquickstyle.pro @@ -5,3 +5,4 @@ SOURCES += tst_qquickstyle.cpp osx:CONFIG -= app_bundle QT += quickcontrols2 testlib +QT_PRIVATE += core-private gui-private quickcontrols2-private diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index b4da3045..15edc67b 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -38,15 +38,28 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQuickControls2/qquickstyle.h> +#include <QtQuickControls2/private/qquickstyle_p.h> +#include <QtGui/private/qguiapplication_p.h> class tst_QQuickStyle : public QObject { Q_OBJECT private slots: + void init(); void lookup(); + void commandLineArgument(); + void environmentVariables(); }; +void tst_QQuickStyle::init() +{ + QQuickStylePrivate::reset(); + QGuiApplicationPrivate::styleOverride.clear(); + qunsetenv("QT_QUICK_CONTROLS_STYLE"); + qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE"); +} + void tst_QQuickStyle::lookup() { QVERIFY(QQuickStyle::name().isEmpty()); @@ -58,7 +71,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()); @@ -67,6 +80,20 @@ void tst_QQuickStyle::lookup() QVERIFY(!QQuickStyle::path().isEmpty()); } +void tst_QQuickStyle::commandLineArgument() +{ + QGuiApplicationPrivate::styleOverride = "CmdLineArgStyle"; + QCOMPARE(QQuickStyle::name(), QString("CmdLineArgStyle")); +} + +void tst_QQuickStyle::environmentVariables() +{ + qputenv("QT_QUICK_CONTROLS_STYLE", "EnvVarStyle"); + qputenv("QT_QUICK_CONTROLS_FALLBACK_STYLE", "EnvVarFallbackStyle"); + QCOMPARE(QQuickStyle::name(), QString("EnvVarStyle")); + QCOMPARE(QQuickStylePrivate::fallbackStyle(), QString("EnvVarFallbackStyle")); +} + QTEST_MAIN(tst_QQuickStyle) #include "tst_qquickstyle.moc" 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/Control.qml b/tests/auto/qquickstyleselector/data/Control.qml new file mode 100644 index 00000000..697662f6 --- /dev/null +++ b/tests/auto/qquickstyleselector/data/Control.qml @@ -0,0 +1,2 @@ +import QtQuick.Templates 2.1 as T +T.Control { } diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml new file mode 100644 index 00000000..ee17c230 --- /dev/null +++ b/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml @@ -0,0 +1,2 @@ +import QtQuick.Templates 2.1 as T +T.Button { } diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml new file mode 100644 index 00000000..8879d93f --- /dev/null +++ b/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml @@ -0,0 +1,2 @@ +import QtQuick.Templates 2.1 as T +T.Label { } 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/qquickstyleselector/data/Label.qml b/tests/auto/qquickstyleselector/data/Label.qml new file mode 100644 index 00000000..8879d93f --- /dev/null +++ b/tests/auto/qquickstyleselector/data/Label.qml @@ -0,0 +1,2 @@ +import QtQuick.Templates 2.1 as T +T.Label { } diff --git a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp index 6c2aebe4..1e7d7add 100644 --- a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp +++ b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp @@ -36,6 +36,7 @@ #include <QtTest/qtest.h> #include <QtQuickControls2/qquickstyle.h> +#include <QtQuickControls2/private/qquickstyle_p.h> #include <QtQuickControls2/private/qquickstyleselector_p.h> #include "../shared/util.h" @@ -44,24 +45,82 @@ class tst_QQuickStyleSelector : public QQmlDataTest Q_OBJECT private slots: + void initTestCase(); + void select_data(); void select(); }; +void tst_QQuickStyleSelector::initTestCase() +{ + QQmlDataTest::initTestCase(); + QQuickStylePrivate::init(dataDirectoryUrl()); +} + void tst_QQuickStyleSelector::select_data() { QTest::addColumn<QString>("file"); QTest::addColumn<QString>("style"); QTest::addColumn<QString>("path"); + QTest::addColumn<QString>("fallback"); QTest::addColumn<QString>("expected"); - QTest::newRow("empty") << "Button.qml" << "" << dataDirectory() << testFileUrl("Button.qml").toString(); - QTest::newRow("no such dir") << "Button.qml" << "Foo" << dataDirectory() << testFileUrl("Button.qml").toString(); - QTest::newRow("no such file") << "Foo.qml" << "FileSystemStyle" << dataDirectory() << testFileUrl("Foo.qml").toString(); - QTest::newRow("relative/path/to/FileSystemStyle") << "Button.qml" << "FileSystemStyle" << "data" << testFileUrl("FileSystemStyle/Button.qml").toString(); - QTest::newRow("/absolute/path/to/FileSystemStyle") << "Button.qml" << "FileSystemStyle" << dataDirectory() << testFileUrl("FileSystemStyle/Button.qml").toString(); - QTest::newRow(":/ResourceStyle") << "Button.qml" << "ResourceStyle" << ":/" << "qrc:/ResourceStyle/Button.qml"; - QTest::newRow("qrc:/ResourceStyle") << "Button.qml" << "ResourceStyle" << "qrc:/" << "qrc:/ResourceStyle/Button.qml"; + // Control.qml exists only in the default style + QTest::newRow("control") << "Control.qml" << "" << "data" << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("/control") << "Control.qml" << "" << dataDirectory() << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("fs/control") << "Control.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("/fs/control") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString(); + QTest::newRow(":/control") << "Control.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("qrc:/control") << "Control.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("nosuch/control") << "Control.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Control.qml").toString(); + QTest::newRow("/nosuch/control") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString(); + + QTest::newRow("control->base") << "Control.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("/control->base") << "Control.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("fs/control->base") << "Control.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("/fs/control->base") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow(":/control->base") << "Control.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("qrc:/control->base") << "Control.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("nosuch/control->base") << "Control.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString(); + QTest::newRow("/nosuch/control->base") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString(); + + // Label.qml exists in the default and fallback styles + QTest::newRow("label") << "Label.qml" << "" << "data" << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("/label") << "Label.qml" << "" << dataDirectory() << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("fs/label") << "Label.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("/fs/label") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString(); + QTest::newRow(":/label") << "Label.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("qrc:/label") << "Label.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("nosuch/label") << "Label.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Label.qml").toString(); + QTest::newRow("/nosuch/label") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString(); + + QTest::newRow("label->base") << "Label.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow("/label->base") << "Label.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Label.qml").toString(); + QTest::newRow("fs/label->base") << "Label.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow("/fs/label->base") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow(":/label->base") << "Label.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow("qrc:/label->base") << "Label.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow("nosuch/label->base") << "Label.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + QTest::newRow("/nosuch/label->base") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString(); + + // Button.qml exists in all styles including the fs and qrc styles + QTest::newRow("button") << "Button.qml" << "" << "data" << "" << testFileUrl("Button.qml").toString(); + QTest::newRow("/button") << "Button.qml" << "" << dataDirectory() << "" << testFileUrl("Button.qml").toString(); + QTest::newRow("fs/button") << "Button.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("FileSystemStyle/Button.qml").toString(); + QTest::newRow("/fs/button") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("FileSystemStyle/Button.qml").toString(); + QTest::newRow(":/button") << "Button.qml" << "ResourceStyle" << ":/" << "" << "qrc:/ResourceStyle/Button.qml"; + QTest::newRow("qrc:/button") << "Button.qml" << "ResourceStyle" << "qrc:/" << "" << "qrc:/ResourceStyle/Button.qml"; + QTest::newRow("nosuch/button") << "Button.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Button.qml").toString(); + QTest::newRow("/nosuch/button") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Button.qml").toString(); + + QTest::newRow("button->base") << "Button.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString(); + QTest::newRow("/button->base") << "Button.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Button.qml").toString(); + QTest::newRow("fs/button->base") << "Button.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString(); + QTest::newRow("/fs/button->base") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString(); + QTest::newRow(":/button->base") << "Button.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml"; + QTest::newRow("qrc:/button->base") << "Button.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml"; + QTest::newRow("nosuch/button->base") << "Button.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString(); + QTest::newRow("/nosuch/button->base") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString(); } void tst_QQuickStyleSelector::select() @@ -69,9 +128,11 @@ void tst_QQuickStyleSelector::select() QFETCH(QString, file); QFETCH(QString, style); QFETCH(QString, path); + QFETCH(QString, fallback); QFETCH(QString, expected); QQuickStyle::setStyle(QDir(path).filePath(style)); + QQuickStyle::setFallbackStyle(fallback); QQuickStyleSelector selector; selector.setBaseUrl(dataDirectoryUrl()); 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 { } |