diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tableview/table_delegate3.qml | 3 | ||||
-rw-r--r-- | tests/auto/controls/data/tableview/table_mousearea.qml | 3 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_applicationwindow.qml | 1 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_calendar.qml | 42 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_slider.qml | 14 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_splitview.qml | 73 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_switch.qml | 30 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tableview.qml | 12 | ||||
-rw-r--r-- | tests/manual/texthandles/main.cpp | 49 | ||||
-rw-r--r-- | tests/manual/texthandles/main.qml | 220 | ||||
-rw-r--r-- | tests/manual/texthandles/texthandles.pro | 11 | ||||
-rw-r--r-- | tests/manual/texthandles/texthandles.qmlproject | 16 | ||||
-rw-r--r-- | tests/manual/texthandles/texthandles.qrc | 5 |
13 files changed, 475 insertions, 4 deletions
diff --git a/tests/auto/controls/data/tableview/table_delegate3.qml b/tests/auto/controls/data/tableview/table_delegate3.qml index 48eb9510..e1c20a10 100644 --- a/tests/auto/controls/data/tableview/table_delegate3.qml +++ b/tests/auto/controls/data/tableview/table_delegate3.qml @@ -48,6 +48,7 @@ TableView { property bool _clicked: false property bool _released: false property bool _doubleClicked: false + property bool _pressAndHold: false headerVisible: false @@ -56,6 +57,7 @@ TableView { _released = false _clicked = false _doubleClicked = false + _pressAndHold = false } TableViewColumn { @@ -71,6 +73,7 @@ TableView { onClicked: table._clicked = true onReleased: table._released = true onDoubleClicked: table._doubleClicked = true + onPressAndHold: table._pressAndHold = true } } } diff --git a/tests/auto/controls/data/tableview/table_mousearea.qml b/tests/auto/controls/data/tableview/table_mousearea.qml index c21e54ce..d96ca842 100644 --- a/tests/auto/controls/data/tableview/table_mousearea.qml +++ b/tests/auto/controls/data/tableview/table_mousearea.qml @@ -49,6 +49,7 @@ TableView { property bool _clicked: false property bool _released: false property bool _doubleClicked: false + property bool _pressAndHold: false headerVisible: false @@ -57,6 +58,7 @@ TableView { _released = false _clicked = false _doubleClicked = false + _pressAndHold = false } TableViewColumn { @@ -73,5 +75,6 @@ TableView { onClicked: table._clicked = true onReleased: table._released = true onDoubleClicked: table._doubleClicked = true + onPressAndHold: table._pressAndHold = true } } diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml index 91e8c2e5..85c88ece 100644 --- a/tests/auto/controls/data/tst_applicationwindow.qml +++ b/tests/auto/controls/data/tst_applicationwindow.qml @@ -41,6 +41,7 @@ import QtQuick 2.2 import QtTest 1.0 import QtQuickControlsTests 1.0 +import QtQuick.Window 2.1 Item { id: container diff --git a/tests/auto/controls/data/tst_calendar.qml b/tests/auto/controls/data/tst_calendar.qml index 870b5552..a0035fcb 100644 --- a/tests/auto/controls/data/tst_calendar.qml +++ b/tests/auto/controls/data/tst_calendar.qml @@ -78,6 +78,10 @@ Item { id: releasedSignalSpy } + SignalSpy { + id: pressAndHoldSignalSpy + } + function init() { calendar = Qt.createQmlObject("import QtQuick.Controls 1.2; " + " Calendar { }", container, ""); @@ -91,6 +95,7 @@ Item { pressedSignalSpy.clear(); clickedSignalSpy.clear(); releasedSignalSpy.clear(); + pressAndHoldSignalSpy.clear(); } function toPixelsX(cellPosX) { @@ -668,7 +673,7 @@ Item { compare(hoveredSignalSpy.count, 0); compare(pressedSignalSpy.count, 0); compare(releasedSignalSpy.count, 1); - compare(clickedSignalSpy.count, 1); + compare(clickedSignalSpy.count, 0); hoveredSignalSpy.clear(); pressedSignalSpy.clear(); @@ -854,5 +859,40 @@ Item { } } } + + function test_pressAndHold() { + calendar.selectedDate = new Date(2013, 0, 1); + calendar.__locale = Qt.locale("en_GB"); + + pressedSignalSpy.target = calendar; + pressedSignalSpy.signalName = "pressed"; + + releasedSignalSpy.target = calendar; + releasedSignalSpy.signalName = "released"; + + pressAndHoldSignalSpy.target = calendar; + pressAndHoldSignalSpy.signalName = "pressAndHold"; + + /* January 2013 + M T W T F S S + 31 1 2 3 4 5 6 + 7 8 9 10 11 12 [13] + 14 15 16 17 18 19 20 + 21 22 23 24 25 26 27 + 28 29 30 31 1 2 3 + 4 5 6 7 8 9 10 */ + mousePress(calendar, toPixelsX(6), toPixelsY(1), Qt.LeftButton); + compare(calendar.__panel.pressedCellIndex, 13); + compare(pressedSignalSpy.count, 1); + compare(releasedSignalSpy.count, 0); + compare(pressAndHoldSignalSpy.count, 0); + tryCompare(pressAndHoldSignalSpy, "count", 1); + + mouseRelease(calendar, toPixelsX(6), toPixelsY(1), Qt.LeftButton); + compare(calendar.__panel.pressedCellIndex, -1); + compare(pressedSignalSpy.count, 1); + compare(releasedSignalSpy.count, 1); + compare(pressAndHoldSignalSpy.count, 1); + } } } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index e5614566..3836fdde 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -100,12 +100,20 @@ Item { slider.minimumValue = 0 slider.value = 1 slider.stepSize = 1 - var keyStep = 2 // (maximumValue - minimumValue)/10.0 keyPress(Qt.Key_Right) keyPress(Qt.Key_Right) - compare(slider.value, 1 + keyStep * 2) + compare(slider.value, 1 + slider.stepSize * 2) keyPress(Qt.Key_Left) - compare(slider.value, 1 + keyStep) + compare(slider.value, 1 + slider.stepSize) + + slider.stepSize = 5 + slider.value = 15 + keyPress(Qt.Key_Right) + compare(slider.value, 20) + keyPress(Qt.Key_Right) + compare(slider.value, 20) + keyPress(Qt.Key_Left) + compare(slider.value, 15) slider.destroy() } diff --git a/tests/auto/controls/data/tst_splitview.qml b/tests/auto/controls/data/tst_splitview.qml index 64436c46..dfc55c94 100644 --- a/tests/auto/controls/data/tst_splitview.qml +++ b/tests/auto/controls/data/tst_splitview.qml @@ -213,4 +213,77 @@ TestCase { compare (view.item3.x, view.width - view.item3.width) view.destroy() } + + Component { + id: item_to_add_dynamically + Rectangle { + width: 50 + height: 100 + color: "yellow" + } + } + + function test_dynamic_item_add() { + // QTBUG-35281 + var view = splitView.createObject(testCase); + verify (view !== null, "splitview created is null") + verify (view.orientation === Qt.Horizontal) + waitForRendering(view) + + var item3 = item_to_add_dynamically.createObject() + view.addItem(item3) + // reset item2 width + view.item2.width = 200 + waitForRendering(view) + + compare (view.__items.length, 3) + + compare (view.item1.x, 0) + compare (view.item1.y, 0) + compare (view.item1.width, 100) + compare (view.item1.height, 500) + + compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) + compare (view.item2.y, 0) + compare (view.item2.width, 200) + compare (view.item2.height, 500) + + compare (item3.x, view.item2.x + view.item2.width + handleWidth) + compare (item3.y, 0) + compare (item3.width, testCase.width - view.item2.width - view.item1.width - (handleWidth*2)) + compare (item3.height, 500) + + view.destroy() + } + + function test_dynamic_item_add_fillWidth() { + var view = splitView.createObject(testCase); + verify (view !== null, "splitview created is null") + verify (view.orientation === Qt.Horizontal) + view.item2.Layout.fillWidth = true + waitForRendering(view) + + var item3 = item_to_add_dynamically.createObject() + view.addItem(item3) + waitForRendering(view) + + compare (view.__items.length, 3) + + compare (view.item1.x, 0) + compare (view.item1.y, 0) + compare (view.item1.width, 100) + compare (view.item1.height, 500) + + compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) + compare (view.item2.y, 0) + compare (view.item2.width, testCase.width - view.item1.width - item3.width - (handleWidth*2)) + compare (view.item2.height, 500) + + compare (item3.x, view.item2.x + view.item2.width + handleWidth) + compare (item3.y, 0) + compare (item3.width, 50) + compare (item3.height, 500) + + view.destroy() + } } diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index dad39301..2cfd1008 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -102,6 +102,36 @@ Item { compare(aSwitch.checked, true); } + function test_pressed() { + signalSpy.signalName = "pressedChanged" + signalSpy.target = aSwitch; + compare(signalSpy.count, 0); + compare(aSwitch.pressed, false); + + mousePress(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(aSwitch.pressed, true); + compare(signalSpy.count, 1); + + mouseRelease(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(aSwitch.pressed, false); + compare(signalSpy.count, 2); + } + + function test_clicked() { + signalSpy.signalName = "clicked" + signalSpy.target = aSwitch; + compare(signalSpy.count, 0); + + mouseClick(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(signalSpy.count, 1); + + // release outside -> no clicked() + mousePress(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + mouseMove(aSwitch, aSwitch.x - 1, aSwitch.y - 1, Qt.LeftButton); + mouseRelease(aSwitch, aSwitch.x - 1, aSwitch.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + } + function test_keyPressed() { aSwitch.forceActiveFocus(); signalSpy.signalName = "checkedChanged"; diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index c99d2dcd..40eb5843 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -542,6 +542,7 @@ TestCase { compare(table._clicked, false) compare(table._released, false) compare(table._doubleClicked, false) + compare(table._pressAndHold, false) mousePress(table, 25 , 10, Qt.LeftButton) compare(table._pressed, true) @@ -559,6 +560,11 @@ TestCase { compare(table._doubleClicked, true) table.clearTestData() + mousePress(table, 25 , 10, Qt.LeftButton) + compare(table._pressAndHold, false) + tryCompare(table, "_pressAndHold", true, 5000) + table.clearTestData() + table.destroy() } @@ -580,6 +586,7 @@ TestCase { compare(table._clicked, false) compare(table._released, false) compare(table._doubleClicked, false) + compare(table._pressAndHold, false) mousePress(table, 25, 10, Qt.RightButton) compare(table._pressed, true) @@ -597,6 +604,11 @@ TestCase { compare(table._doubleClicked, true) table.clearTestData() + mousePress(table, 25 , 10, Qt.RightButton) + compare(table._pressAndHold, false) + tryCompare(table, "_pressAndHold", true, 5000) + table.clearTestData() + table.destroy() } diff --git a/tests/manual/texthandles/main.cpp b/tests/manual/texthandles/main.cpp new file mode 100644 index 00000000..210d777e --- /dev/null +++ b/tests/manual/texthandles/main.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/tests/manual/texthandles/main.qml b/tests/manual/texthandles/main.qml new file mode 100644 index 00000000..ab10b861 --- /dev/null +++ b/tests/manual/texthandles/main.qml @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 + +ApplicationWindow { + id: window + + width: 800 + height: 480 + visible: true + + toolBar: ToolBar { + RowLayout { + anchors.fill: parent + anchors.margins: window.spacing + CheckBox { + id: selectBox + text: "SelectByMouse" + checked: true + } + CheckBox { + id: handleBox + text: "Handles" + checked: true + enabled: selectBox.checked + } + CheckBox { + id: outlineBox + text: "Outlines" + checked: false + enabled: handleBox.enabled && handleBox.checked + } + Item { width: 1; height: 1; Layout.fillWidth: true } + CheckBox { + id: wrapBox + text: "Wrap" + checked: true + } + } + } + + property int spacing: edit.font.pixelSize / 2 + + property string loremIpsum: "Lorem ipsum dolor sit amet, <a href='http://qt.digia.com'>consectetur</a> adipiscing elit. " + + "Morbi varius a lorem ac blandit. Donec eu nisl eu nisi consectetur commodo. " + + "Vestibulum tincidunt <img src='http://qt.digia.com/Static/Images/QtLogo.png'>ornare</img> tempor. " + + "Nulla dolor dui, vehicula quis tempor quis, ullamcorper vel dui. " + + "Integer semper suscipit ante, et luctus magna malesuada sed. " + + "Sed ipsum velit, pellentesque non aliquam eu, bibendum ac magna. " + + "Donec et luctus dolor. Nulla semper quis neque vitae cursus. " + + "Etiam auctor, ipsum vel varius tincidunt, erat lacus pulvinar sem, eu egestas leo nulla non felis. " + + "Maecenas hendrerit commodo turpis, ac convallis leo congue id. " + + "Donec et egestas ante, a dictum sapien." + + ColumnLayout { + spacing: window.spacing + anchors.margins: window.spacing + anchors.fill: parent + + TextField { + id: field + z: 1 + text: loremIpsum + Layout.fillWidth: true + selectByMouse: selectBox.checked + + style: TextFieldStyle { + cursorHandle: handleBox.checked ? cursorDelegate : null + selectionHandle: handleBox.checked ? selectionDelegate : null + } + } + + SpinBox { + id: spinbox + z: 1 + decimals: 2 + value: 500000 + maximumValue: 1000000 + Layout.fillWidth: true + selectByMouse: selectBox.checked + horizontalAlignment: Qt.AlignHCenter + + style: SpinBoxStyle { + cursorHandle: handleBox.checked ? cursorDelegate : null + selectionHandle: handleBox.checked ? selectionDelegate : null + } + } + + ComboBox { + id: combobox + z: 1 + editable: true + currentIndex: 1 + Layout.fillWidth: true + selectByMouse: selectBox.checked + model: ListModel { + id: combomodel + ListElement { text: "Apple" } + ListElement { text: "Banana" } + ListElement { text: "Coconut" } + ListElement { text: "Orange" } + } + onAccepted: { + if (find(currentText) === -1) { + combomodel.append({text: editText}) + currentIndex = find(editText) + } + } + + style: ComboBoxStyle { + cursorHandle: handleBox.checked ? cursorDelegate : null + selectionHandle: handleBox.checked ? selectionDelegate : null + } + } + + TextArea { + id: edit + Layout.fillWidth: true + Layout.fillHeight: true + + textFormat: Qt.RichText + selectByMouse: selectBox.checked + wrapMode: wrapBox.checked ? Text.Wrap : Text.NoWrap + text: loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum + + style: TextAreaStyle { + cursorHandle: handleBox.checked ? cursorDelegate : null + selectionHandle: handleBox.checked ? selectionDelegate : null + } + } + } + + Component { + id: selectionDelegate + Rectangle { + x: -width + edit.font.pixelSize / 2 + y: (styleData.lineHeight - height) / 2 + width: edit.font.pixelSize * 2.5 + height: edit.font.pixelSize * 2.5 + border.width: outlineBox.checked ? 1 : 0 + radius: width / 4 + color: "transparent" + Rectangle { + color: "white" + border.width: 1 + radius: width / 2 + width: height + height: edit.font.pixelSize / 2 + anchors.right: parent.right + anchors.rightMargin: width / 2 + anchors.verticalCenter: parent.verticalCenter + visible: control.activeFocus && styleData.hasSelection + } + } + } + + Component { + id: cursorDelegate + Rectangle { + x: styleData.hasSelection ? -edit.font.pixelSize / 2 : -width / 2 + y: (styleData.lineHeight - height) / 2 + width: edit.font.pixelSize * 2.5 + height: edit.font.pixelSize * 2.5 + border.width: outlineBox.checked ? 1 : 0 + radius: width / 4 + color: "transparent" + Rectangle { + color: "white" + border.width: 1 + radius: width / 2 + width: height + height: edit.font.pixelSize / 2 + anchors.left: parent.left + anchors.leftMargin: width / 2 + anchors.verticalCenter: parent.verticalCenter + visible: control.activeFocus && styleData.hasSelection + } + } + } +} diff --git a/tests/manual/texthandles/texthandles.pro b/tests/manual/texthandles/texthandles.pro new file mode 100644 index 00000000..0c7c00d8 --- /dev/null +++ b/tests/manual/texthandles/texthandles.pro @@ -0,0 +1,11 @@ +TARGET = texthandles +QT += qml quick + +SOURCES += \ + $$PWD/main.cpp + +OTHER_FILES += \ + $$PWD/main.qml + +RESOURCES += \ + texthandles.qrc diff --git a/tests/manual/texthandles/texthandles.qmlproject b/tests/manual/texthandles/texthandles.qmlproject new file mode 100644 index 00000000..e5a8bf02 --- /dev/null +++ b/tests/manual/texthandles/texthandles.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/tests/manual/texthandles/texthandles.qrc b/tests/manual/texthandles/texthandles.qrc new file mode 100644 index 00000000..5f6483ac --- /dev/null +++ b/tests/manual/texthandles/texthandles.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> |